0.0.1 • Published 2 years ago
ts-weighted-random v0.0.1
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);
License
0.0.1
2 years ago