random-pick-js
v1.0.6
Published
Pick random items from an array within given weights
Downloads
13
Maintainers
Readme
random-pick-js
Picks random items from an array within given weights
Installation
npm i random-pick-js
Usage
import { randomPick } from 'random-pick-js'
const picked = randomPick(['icecream', 'cookie', 'anything', 'chicken', 'pizza'], {
cnt: 2,
weights: [1, 3, 10, 2, 7]
});
console.log(picked); // example output: ['anything', 'chicken']