-
-
Notifications
You must be signed in to change notification settings - Fork 804
[RFC]: add utils/async/parallel
#1811
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
Comments
👋 Hi there! 👋 And thank you for opening your first issue! We will get back to you shortly. 🏃 💨 |
I'd like to work on it ASAP as part of my proposal for the mentioned project. |
@Deadreyo This is looking good. I suggest making
I don't think this should be required, and I don't think we have a way to enforce this. So long as each provided function calls a provided
This makes sense to me. I don't see an imperative to have two separate APIs.
Should we also support providing an object, similar to |
I agree with all your points.
Comparing with |
For |
Alright I now understand what you mean, this example: async.parallel({
one: function(callback) {
setTimeout(function() {
callback(null, 1);
}, 200);
},
two: function(callback) {
setTimeout(function() {
callback(null, 2);
}, 100);
}
}, function(err, results) {
console.log(results);
// results is equal to: { one: 1, two: 2 }
}); It's fine by me either of the decisions, implementing both at this moment, or implementing only the array now and pushing the object to a separate issue/task, where we can discuss the arguments for both sides more freely. |
For the functions in the functionArray, they should have a
|
I don't think we should require a particular arity for functions in the function array. Users should be able to provide a function of any arity; we don't really care. We always pass in a // Callback function provided by the `parallel` implementation to each function in the function array...
function clbk( error, result ) {
if ( error ) {
// ... handle error
return;
}
// ...handle result
} The onus is on users to ensure they call the callback. And if the arity is zero, they are responsible for extracting the callback from |
Great. I think everything is set. I will start on it |
Awesome. Thanks! |
Finished and opened the PR |
Description
This RFC proposes adding
utils/async/parallel
to run a set of asynchronous code in parallel, corresponding to async.js parallel and async.js parallelLimitRelated Issues
Related to the project idea stdlib-js/google-summer-of-code#9
Questions
No.
Other
The implementation will be inspired by
utils/async/map-values
.The API interface would be
parallel( functionArray [, options] [, done] )
.Params:
options
will accept:thisArg
: execution contextlimit
: maximum number of pending invocations with defaultinfinity
. (Will replace the need for a separate function forparallelLimit
)Checklist
RFC:
.The text was updated successfully, but these errors were encountered: