Permalink
Browse files

Fixed a bug with empty groups.

  • Loading branch information...
1 parent 06c29db commit 19f69618b0cf0acc688887c77cbaedaa864d96c0 @Schoonology committed Feb 24, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/stepdown.js
View
@@ -82,7 +82,7 @@ function alloc(type, hookFn) {
index += adj.amount;
}
});
-
+
if (self[index] !== NO_RESULT) {
throw new Error('Callbacks cannot be reused.');
}
@@ -388,6 +388,12 @@ function _group(count, type) {
count = null;
}
+ // Zero is a special case. We're not actually out of sync, because we're expecting to "generate" an empty set of
+ // callback functions.
+ if (count === 0) {
+ return [];
+ }
+
var self = this,
allocType = ['none', 'ignore'].indexOf(type) !== -1 ? type : 'group',
callback = this.results.alloc(allocType),

0 comments on commit 19f6961

Please sign in to comment.