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

Make fn return a promise? #4

Closed
t0mclaudio opened this issue Feb 28, 2021 · 1 comment
Closed

Make fn return a promise? #4

t0mclaudio opened this issue Feb 28, 2021 · 1 comment

Comments

@t0mclaudio
Copy link

I was just wondering if there is a benefit to making the chunkify function return a Promise? I am thinking of a use case where we pass a large iterable data? I'm sorry if this question is a silly one. 😄

@sindresorhus
Copy link
Owner

It would create more overhead than benefit for most cases. If you really do have a huge data set, you should instead run it in a worker_thread. However, since it's an iterable, you could use it with a for-awaits loop: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of#iterating_over_sync_iterables_and_generators It will still block the main thread, but at least it will give up the main thread for each iteration.

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