-
-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce oneOf helpers function #2674
Comments
Thank you for your feature proposal. We marked it as "waiting for user interest" for now to gather some feedback from our community:
We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements. We will start the implementation based on:
We do this because:
|
Edge cases:
Alternatively:
|
Another benefit of |
|
I don't see the necessity of this potential feature. If you are working with dynamic values you need to create an array anyway. As pointed out before, the static value inference can be done with arrays as well since TypeScript v5.0 with the generic const argument. |
Clear and concise description of the problem
Currently, if you want to select one of a few local values, you have to wrap them explicitly in an array before you can pass them to arrayElement.
Suggested solution
Introduce
faker.helpers.oneOf(...values: T[]): T
that hides the array creation from the user.Alternative
Stay with
arrayElement
only.Additional context
Definition
Usage with arrays
Usage with values
The text was updated successfully, but these errors were encountered: