We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
I need to create an array of objects with a random number of elements.
At the moment I am using Array.fill, followed by Array.map using faker.mersenne.rand to randomize the number of elements of my array.
Is there a way faker could simplify this instead ?
No response
The text was updated successfully, but these errors were encountered:
This is planned as a new feature in v8: #1545 + #1486
faker.helpers.multiple(method: () => T, { count: number | { min: number, max: number }}); faker.helpers.multiple(faker.datatype.number, { count: { min: 5, max: 10 }}); // [ 45614, 684631, 468435, 634639, 95460, 340] faker.helpers.multiple(() => faker.datatype.number({min: 0, max: 1337}), { count: { min: 5, max: 42 }}); // [ 643, 468, 51, 10, 183, ... ]
Current workaround:
const length = faker.datatype.number({ min: 5, max: 10 }); return Array.from({ length }, () => faker.datatype.number({min: 0, max: 1337}) );
Sorry, something went wrong.
This is planned as a new feature in v8: #1545 + #1486 faker.helpers.multiple(method: () => T, { count: number | { min: number, max: number }}); faker.helpers.multiple(faker.datatype.number, { count: { min: 5, max: 10 }}); // [ 45614, 684631, 468435, 634639, 95460, 340] faker.helpers.multiple(() => faker.datatype.number({min: 0, max: 1337}), { count: { min: 5, max: 42 }}); // [ 643, 468, 51, 10, 183, ... ] Current workaround: const length = faker.datatype.number({ min: 5, max: 10 }); return Array.from({ length }, () => faker.datatype.number({min: 0, max: 1337}) );
Thank you, I will be waiting for the multiple method! Your workaround is much better for now!
No branches or pull requests
Clear and concise description of the problem
I need to create an array of objects with a random number of elements.
At the moment I am using Array.fill, followed by Array.map using faker.mersenne.rand to randomize the number of elements of my array.
Suggested solution
Is there a way faker could simplify this instead ?
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: