-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow the loop to end early? #1
Labels
Comments
return pTimes.StopSymbol; is not substantially more verbose than: (i, stop) => {
stop();
return; Plus it has the advantage of being global so you don't have to pass a Alternatively: return pTimes['⛔️']; // 😜 |
Thanks for the feedback. I'll go with returning a Symbol and Pull request welcome from anyone :) |
Because this module wraps |
Yeah, we need to resolve sindresorhus/p-map#31 first. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Normal for loops can end early by using
break
orreturn
. Might be useful to have the ability here too. Does that make sense?Possible implementations:
1
Add a method for ending the iteration in the second argument to
mapper
:mapper(index, stop)
:2
Add ability to throw a special error to end the iteration without rejection the promise:
3
Add ability to return special
Symbol
to end the iteration:While 2 and 3 are more verbose, they have the benefit of working even in a nested promise chain.
The text was updated successfully, but these errors were encountered: