Add method like fake.sample()
that returns specified number N elements from array
#80
Labels
fake.sample()
that returns specified number N elements from array
#80
fake.sample()
takes an array and returns a random element from that array. Occasionally, we have a need to generate an array of N elements out of an array of M elements. Sometimes we have a uniqueness requirement and sometimes we do not.What could we call this? I'm a bit uninspired when it comes to naming this.
Chance.js calls these
pickone
andpickset
, which aren't awful, but we already call ourpickone
sample
.sampleMany
?multiSample
?fake.subset()
is not bad perhaps, at least for the case of unique elements.Would we want separate methods for the unique vs. nonunique case or a flag or just support one or the other?
The text was updated successfully, but these errors were encountered: