random-pick-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i random-pick-js

      Weekly Downloads

      0

      Version

      1.0.6

      License

      MIT

      Unpacked Size

      3.42 kB

      Total Files

      6

      Last publish

      Collaborators

      • changwoolab