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

parallelCollect method. #349

Closed
wants to merge 1 commit into from
Closed

Conversation

daviddenton
Copy link

A solution to issue #334 - regarding async parallel error handling. Added new method, tests and documentation for it.

Generally, this is a version of parallel() which, instead of failing on the first error, continues and gathers all errors. The final callback is called with the error list/object and the result list/object.

I've now implemented this functionality across a few projects - it seems to be something that would be useful in the core.

@daviddenton
Copy link
Author

Apologies - I've just noticed some annoying line break changes have got into the .md file and are rather confusing the diff view of the pull req. The interesting changes in the diff are at the bottom.

If it's a problem and you'd like me to resubmit the request, please let me know and I'll fix it and resubmit.

Thanks.

@iliakan
Copy link

iliakan commented Aug 29, 2013

Looks useful. The cuts of extra spaces in .md looks like is a reasonable change too =)

@caolan
Copy link
Owner

caolan commented Mar 28, 2014

We need a more general solution to this problem. All async functions do early exit on error at the moment, so I don't want to introduce a special alternative for parallel alone.

@caolan caolan closed this Mar 28, 2014
@reggi
Copy link

reggi commented Apr 22, 2014

Here's a general solution I just came up with: https://gist.github.com/reggi/11186741

var collect = function(callback){
  return function(){
    var args = Array.prototype.slice.call(arguments);
    args.unshift(null);
    return callback(null, args);
  }
}

Then within the call: var callback = collect(callback);

@aearly
Copy link
Collaborator

aearly commented Jun 2, 2015

Reopening this for reference, because I think it's the best implementation of this feature. I'd like to figure out how to apply this more broadly.

@aearly
Copy link
Collaborator

aearly commented Oct 25, 2015

Closing this in favor of #942. There are several things to figure out in order to support this type of behavior, then we can re-implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants