ngneat / falso

All the Fake Data for All Your Real Needs 🙂

Home Page:https://ngneat.github.io/falso/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve ToCollection function, in generate random collection length

manudss opened this issue · comments

Description

ToCollection can generate a length of collection in issue #301, It might be nice to have a generation of the number of items randomly. So you don't have a list of the same length all the time.

Proposed solution

Add the options minLength and maxLength, if these options are defined, it will generate the length in a random way.

I propose to use the names of the options like minLength and maxLength instead min and max, which would be in competition with the min and max options of some existing functions.

Alternatives considered

no

Do you want to create a pull request?

Yes

Why isn't it enough to just pass randNumber to the length option?

toCollection(myFunction, { length: randNumber({ min: 20, max: 60 }) }});

And what does toCollection do exactly? When looking at the code it seems like it spits out the output form the function passed in (along with being able to take in length as an optional parameter), what utility does toCollection provide?