Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

pick-random

2.0.0 • Public • Published

pick-random Build Status

Pick random items from a list

Useful for making decisions, picking a winner, or anything else randomness can help you with.

Install

$ npm install --save pick-random

Usage

const pickRandom = require('pick-random');
 
pickRandom(['Sindre', 'Stephen', 'Unicorn', 'Pascal', 'Addy', 'Pony'], {count: 2});
//=> ['Unicorn', 'Pony']

pickRandom(input, [options])

Returns an Array.

input

Type: Array

List to pick from.

options

Type: Object

count

Type: number
Default: 1

Number of picks.

Must be smaller or the same length as input.

Related

License

MIT © Sindre Sorhus

install

npm i pick-random

Downloadsweekly downloads

248

version

2.0.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar