Permalink
Browse files

bug: nil arguments replaced with error fn

  • Loading branch information...
1 parent 7d9099b commit d0cdca7a3b905099f8f21d3870e94846c94914c1 @logicalparadox logicalparadox committed Jan 1, 2014
Showing with 9 additions and 2 deletions.
  1. +2 −1 index.js
  2. +7 −1 test/arguments.js
View
@@ -35,7 +35,6 @@ function co(fn) {
// with a generator, so optimize for
// this case
var gen = fn;
- done = done || error;
if (isGenFun) {
// we only need to parse the arguments
@@ -50,6 +49,8 @@ function co(fn) {
else done = error;
gen = fn.apply(this, args);
+ } else {
+ done = done || error;
}
next();
View
@@ -6,4 +6,10 @@ describe('co()(args...)', function(){
it('should not pass the thunk as an arguments', co(function *(){
assert.equal(arguments.length, 0);
}))
-})
+
+ it('should not pass error for nil first argument', function(done){
+ co(function *(i){
+ assert.equal(i, 0);
+ })(0, done);
+ });
+})

0 comments on commit d0cdca7

Please sign in to comment.