Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Created June 5, 2017 15:29
Show Gist options
  • Save bluepnume/6c332bb08e7d323b3bdda0f657ecd602 to your computer and use it in GitHub Desktop.
Save bluepnume/6c332bb08e7d323b3bdda0f657ecd602 to your computer and use it in GitHub Desktop.
// Implement async.parallel
// It should take: 1. An array of asynchronous functions, 2. A final callback
// It should run all of the functions in parallel (just like in the ajax exercise)
// When all the calls are complete, it should call finalCallback with an array of the results from each call
// If there is any error, it should call finalCallback with the first error that comes from any of the functions
// It should only call finalCallback *one* time, either with an error, or with an array of results
async.parallel = function(functions, finalCallback) {
}
// Example call:
async.parallel([
function(callback) {
// do something then call callback
},
function(callback) {
// do something then call callback
},
function(callback) {
// do something then call callback
}
], function(err, results) {
// this final callback should be called when all of the previous functions completed, or one of them errored out
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment