@unction/samplesize
v16.15.0
Published
Returns a random number of members from a array or string
Downloads
29
Readme
@unction/sampleSize
number => OrderedArray | Set | Record<string | number | symbol, B> | Map<B, A> | string => OrderedArray | Set | Record<string | number | symbol, B> | Map<B, A> | string
Takes an Array or string and randomly picks n elements to return, but never the same one.
users() // => [{"id": 1, "name": "Kurtis Rainbolt-Greene"}, {"id": 2, "name": "Angela Englund"}]
sample(1)(users()) // => [{"id": 2, "name": "Angela Englund"}]
sample(2)(users()) // => [{"id": 2, "name": "Angela Englund"}, {"id": 1, "name": "Kurtis Rainbolt-Greene"}]