Conversation
|
It doesn't say in the documentation what happens when there's an error in |
| } | ||
| error = err; | ||
| result = args; | ||
| callback(args); |
There was a problem hiding this comment.
Related to the discussion in #1248. Should this be callback(!err)? If the task returns an error and a partial result (e.g. {}), the function should probably move onto the next task as opposed to returning.
There was a problem hiding this comment.
You're right. It should be callback(!err). I'll change it today.
|
I would be in favour of resolving #1248 before moving forward with this PR. |
| * @memberOf module:ControlFlow | ||
| * @method | ||
| * @category Control Flow | ||
| * @name series |
There was a problem hiding this comment.
Just an fyi, some of the JSDoc tags were duplicated here.
|
@hargasinski I have fixed the issues you mentioned :) |
|
I think this is really cumbersome to expect people to implement with function nihTryEach(fns, done) {
var lastResult;
var lastError;
async.some(fns, function (fn, cb) {
fn(function(err, result) {
lastErr = err;
lastResult = result;
cb(null, !err);
});
}, function (err, anySucceeded) {
if (!anySucceeded) return done(lastError);
done(null, lastResult);
}
}It's slightly more complicated than @alFReD-NSH 's implementation. I also think the concerns in #1248 wouldn't affect this implementation, we can deal with those separately. I'd say this is good to merge as-is now. 👍 |
|
Released in v2.4.0! |
This adds async.tryEach which fixes what was requested in #687. I needed something with similar requirements. My use case was that I needed to get some data, which I could get it from 3 websites(with slightly different code for each) but sometimes they go down randomly.
The name might be reconsidered. We can't use
trybecause it's a reserved word. I couldn't think of anything better.You guys might want to also review the documentation, English is not my first language.
As you can see I wrote tests covering most cases, and the coverage is 100% for the file.