Skip to content
Browse files

Made next.parallel more consistent with next.group

  • Loading branch information...
1 parent 2f654d6 commit 2f0a49d04ae55c61acdd7741fdf260b1868cfebb @xavi- xavi- committed Feb 6, 2011
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/step.js
View
11 lib/step.js
@@ -64,25 +64,24 @@ function Step() {
next.parallel = function () {
var i = counter;
counter++;
+
function check() {
- counter--;
if (counter === 0) {
// When they're all done, call the callback
next.apply(null, results);
}
}
+ process.nextTick(check); // Ensures that check is called at least once
+
return function () {
+ counter--;
// Compress the error from any result to the first argument
if (arguments[0]) {
results[0] = arguments[0];
}
// Send the other results as arguments
results[i + 1] = arguments[1];
- if (lock) {
- process.nextTick(check);
- return
- }
- check();
+ if (!lock) { check(); }
};
};

0 comments on commit 2f0a49d

Please sign in to comment.
Something went wrong with that request. Please try again.