Champ · Weighted Array Element

Champ · Weighted Array Element · helpers.weightedArrayElement. Méthode de génération · Exemple

helpers.weightedArrayElement

Options du générateur

Générez des données pour les voir ici.

Paramètres & Exemple

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.

Exemple

"draft"

Utilisez des données synthétiques dans un environnement de test.

Générateurs associés

Explorer les scénarios