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

feat(toCollection): add a new generators to generate collection from … #302

Merged
merged 2 commits into from
Aug 17, 2022

Conversation

manudss
Copy link
Contributor

@manudss manudss commented Aug 11, 2022

…a generator function

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

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.

[ ] Bugfix
[x ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The fake function is internal and can Not bu used externaly.

Issue Number: #301

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x ] No

…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
const expectedData: fakeData = { data: 1 };
randNumberSpy.mockReturnValueOnce(1).mockReturnValueOnce(2);
expect(
toCollection<fakeData, { length: number }>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need the explicitly define the generics in each call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, it's just a habit, where in our project, we force type every time! And we forbid any. I will make the correction.

@NetanelBasal NetanelBasal merged commit ca66e1e into ngneat:main Aug 17, 2022
@manudss manudss deleted the add_to_collection_generator branch August 17, 2022 09:11
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

Successfully merging this pull request may close these issues.

None yet

2 participants