pick-some

1.0.3 • Public • Published

Build Status License: MIT

pick-some

Simple utility to pick, select, choose random items from an array. Items can be chosen uniquely and/or sequentially.

api

pickSome(amount: number, [options: object], arr: array);

options = { unique: boolean, sequential: boolean }

example

const { pickSome } = require('pick-some');

// basic use
pickSome(3, [1,2,3,4,5]) // => [2,5,5]

// unqiue items only
pickSome(3, { unique: true }, [1,2,3,4,5]) // => [3,5,1]

// sequential pick
pickSome(3, { sequential: true }, [1,2,3,4,5]) // => [3,3,4]

// sequential & unique pick
pickSome(3, { unique: true, sequential: true }, [1,2,3,4,5]) // => [2,3,5]

// additional helpers
const { pickSomeUnique, pickSomeSequential } = require('pick-some');
pickSomeUnique(3, [1,2,3,4,5]) // => [3,5,1]
pickSomeSequential(3, [1,2,3,4,5]) // => [3,3,4]

license

MIT

Dependents (1)

Package Sidebar

Install

npm i pick-some

Weekly Downloads

19

Version

1.0.3

License

ISC

Unpacked Size

6.66 kB

Total Files

8

Last publish

Collaborators

  • dve