-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Always run limited functions asynchronously #28
Always run limited functions asynchronously #28
Conversation
This modifies the generator function returned from plimit to always run functions passed to limit asynchronously. This is done by modifying the enqueue method to always push the function provided to the generator function onto the queue and then scheduling a function to run asynchronously to dequeue and run that function. I thought using using `Promise.resolve().then()` was a nice way to schedule that dequeuing function asynchronously because it wasn't too node-specific or browser-specific, but I'm happy to do something else like preferring `process.nextTick` and then falling back to `setTimeout` if `process.nextTick` isn't available.
It really depends on how much breathing room we want to give it. |
Hey @sindresorhus, it looks like the node 6 test failed from using |
I plan to target Node.js 10 after this PR, so just ignore anything lower. |
Thanks for fixing this 🙌 |
This is now published: https://github.com/sindresorhus/p-limit/releases/tag/v3.0.0 |
This modifies the generator function returned from plimit to always
run functions passed to limit asynchronously.
This is done by modifying the enqueue method to always push the function
provided to the generator function onto the queue and then scheduling a
function to run asynchronously to dequeue and run that function.
I thought using using
Promise.resolve().then()
was a nice way toschedule that dequeuing function asynchronously because it wasn't too
node-specific or browser-specific, but I'm happy to do something else
like preferring
process.nextTick
and then falling back tosetTimeout
if
process.nextTick
isn't available.Closes #22