Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Groups with zero tasks are now terminated.

  • Loading branch information...
commit c5116c4270f11915315e679a2cea3f03e503ad12 1 parent 4a82870
@xavi- xavi- authored
Showing with 14 additions and 16 deletions.
  1. +13 −15 lib/step.js
  2. +1 −1  test/groupTest.js
View
28 lib/step.js
@@ -94,32 +94,30 @@ function Step() {
var counter = 0;
var result = [];
var error = undefined;
+
+ function check() {
+ if (counter === 0) {
+ // When group is done, call the callback
+ localCallback(error, result);
+ }
+ }
+ process.nextTick(check); // Ensures that check is called at least once
+
// Generates a callback for the group
return function () {
var i = counter;
counter++;
- function check() {
- counter--;
- if (counter === 0) {
- // When they're all done, call the callback
- localCallback(error, result);
- }
- }
return function () {
+ counter--;
// Compress the error from any result to the first argument
if (arguments[0]) {
error = arguments[0];
}
// Send the other results as arguments
result[i] = arguments[1];
- if (lock) {
- process.nextTick(check);
- return
- }
- check();
- }
-
- }
+ if (!lock) { check(); }
+ };
+ };
};
// Start the engine an pass nothing to the first step.
View
2  test/groupTest.js
@@ -45,4 +45,4 @@ Step(
fulfill('five');
assert.deepEqual(results, []);
}
-);
+);
Please sign in to comment.
Something went wrong with that request. Please try again.