1.0.6 • Published 2 years ago

random-pick-js v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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']