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

Create a collection from a generator function #301

Closed
manudss opened this issue Aug 11, 2022 Discussed in #233 · 0 comments
Closed

Create a collection from a generator function #301

manudss opened this issue Aug 11, 2022 Discussed in #233 · 0 comments

Comments

@manudss
Copy link
Contributor

manudss commented Aug 11, 2022

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 #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 added a commit to manudss/falso that referenced this issue Aug 11, 2022
…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.

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

No branches or pull requests

2 participants