Skip to content

weightedPick

weightedPick<T>(items, weights): T

Defined in: src/global/collections.ts:197

One element, with probability proportional to its weight.

T

Collection<T>

ArrayLike<number>

T

// "common" ten times as often as "rare".
weightedPick(["common", "rare"], [10, 1]); // "common"