Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method like fake.sample() that returns specified number N elements from array #80

Open
serhalp opened this issue Jan 11, 2021 · 0 comments

Comments

@serhalp
Copy link
Contributor

serhalp commented Jan 11, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant