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 and pickset, which aren't awful, but we already call our pickone 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?
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
pickoneandpickset, which aren't awful, but we already call ourpickonesample.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?