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

4.0.0 • Public • Published

pick-random

Pick random items from a list

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

Install

$ npm install pick-random

Usage

import pickRandom from 'pick-random';

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

pickRandom(input, options?)

Returns an Array.

input

Type: Array

The list to pick from.

options

Type: object

count

Type: number
Default: 1

The number of picks.

Must be smaller or the same length as input.

Related

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i pick-random

    Weekly Downloads

    1,292

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    3.49 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus