Skip to content

weightedPick

weightedPick<T>(items, weights): T

Defined in: src/secure.ts:292

One element, with probability proportional to its weight.

T

Collection<T>

ArrayLike<number>

T

weightedPick(["common", "rare"], [10, 1]); // "common"