falso icon indicating copy to clipboard operation
falso copied to clipboard

Create a collection from a generator function

Open manudss opened this issue 3 years ago • 0 comments

add a new generators to generate collection from a generator function

Generate a collection from a custom generators functions

@category util

@example

toCollection(() => { return { data: randNumber(); } })

@example

toCollection(() => { return { data: randNumber(); } }, { length: 10 }) // default is no length.

It is a wrapper for the internal fake function.

Discussed in https://github.com/ngneat/falso/discussions/233

Originally posted by jongbonga March 23, 2022 I want to create a collection of custom objects

e.g: const customObject = {this: randBoolean(), that: randShape(), ...} hand have and array of [customObject, ...].

Do I need to handle it myself with a loop or there is something randCollection({collection: customObject, length: 5}) already (I've gone through the doc and couldn't find such)?.

manudss avatar Aug 11 '22 15:08 manudss