Weighted Array Element generator
Returns a weighted random element from the given array. Each element of the array should be an object with two keys weight and value.
helpers.weightedArrayElement
Generator settings
Generate data to see results here.
Parameters & Example
Returns a weighted random element from the given array. Each element of the array should be an object with two keys weight and value.
helpers.weightedArrayElement(array: ReadonlyArray<{ weight: number; value: T; }>)- array
- Array to pick the value from.
- array[].weight
- The weight of the value.
- array[].value
- The value to pick.
Example
"draft"Use synthetic data in a test environment.