Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

pick-random

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pick-random

Pick random items from a list

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
3.8K
44.29%
Maintainers
1
Weekly downloads
 
Created
Source

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.

CLI

$ npm install --global pick-random
$ pick-random --help

  Usage
    pick-random <arg> <arg> ... [--count <count>]
    cat newline-separated-picks.txt | pick-random

  Example
    pick-random unicorn rainbow cake pony --count 2
    pony
    rainbow

    pick-random yes no
    pick-random $(seq 54) --count 6

API

$ npm install --save pick-random
var pickRandom = require('pick-random');

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

pickRandom(list, options)

Returns an array.

list

Required
Type: array

List to pick from.

options.count

Type: number
Default: 1

Number of picks.

Must be lower than the length of list.

License

MIT © Sindre Sorhus

Keywords

cli

FAQs

Package last updated on 16 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts