npm

Need private packages and team management tools?Check out npm Orgs. »

pick-some

1.0.1 • 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

install

npm i pick-some

Downloadsweekly downloads

9

version

1.0.1

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability