-
Notifications
You must be signed in to change notification settings - Fork 234
Closed
Description
Support weighted faking in custom providers.
Inspired from https://fakerjs.dev/api/helpers#weightedarrayelement
faker.helpers.weightedArrayElement([
{ weight: 5, value: 'sunny' },
{ weight: 4, value: 'rainy' },
{ weight: 1, value: 'snowy' }
]) // 'sunny', 50% of the time, 'rainy' 40% of the time, 'snowy' 10% of the timeWith custom providers, we could make a YML provider with weights associated to each value
en:
faker:
insectsfromfile:
ants: [5, 'Driver ant', 4, 'Fire ant', 1, 'Harvester ant']
Questions
- Is there a way to achieve weighted faking with current codebase ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request