Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a 'isThinking' var to avoid excessive calling to open chain groups

  • Loading branch information...
commit 767889b9e748eea2fb5e0afcc387f3d7fdd42abf 1 parent a127124
@schloerke schloerke authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/groupie.js
View
9 lib/groupie.js
@@ -87,6 +87,7 @@ exports.chain = function () {
fxns = fxns || [];
var pos = 0;
+ var isThinking = false;
var results = [];
var hasMore = function() {
@@ -95,6 +96,7 @@ exports.chain = function () {
var callNext = function() {
var done = function(err, result) {
+ isThinking = false;
if (err) return cb(err, results);
pos++;
@@ -106,6 +108,7 @@ exports.chain = function () {
cb(null, results);
};
try {
+ isThinking = true;
fxns[pos](done);
} catch (err) {
cb(err, results);
@@ -121,11 +124,11 @@ exports.chain = function () {
return {
add: function(fxn) {
fxns.push(fxn);
- if (hasMore()) callNext();
+ if (! isThinking) callNext();
},
finalize: function() {
finalized = true;
- if (!hasMore()) cb(null, results);
+ if (! isThinking) cb(null, results);
}
}
-}
Please sign in to comment.
Something went wrong with that request. Please try again.