ts-weighted-random
v0.0.1
Published
Picks a random value from a list based on the weights
Downloads
1
Readme
ts-weighted-random
Picks a random value from a list based on the weights.
Installation
npm install ts-weighted-random
Usage
import weightedRandom from "ts-weighted-random";
const map = new Map([
[1, 1],
[2, 1],
[3, 5], // This item has 5 times more chances of being picked
]);
weightedRandom(map);