pick-random
Pick random items from a list
Last updated 3 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pick-random 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.0                                ...           latest (3 years ago)

5 Versions

  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |