Comparing version 1.5.0 to 1.5.1
@@ -26,2 +26,10 @@ | ||
yield fun; | ||
}, done); | ||
}, | ||
'function delegation thunk': function(done){ | ||
co(function *(){ | ||
yield fun; | ||
yield fun; | ||
yield fun; | ||
})(done); | ||
@@ -33,3 +41,3 @@ }, | ||
yield [fun, fun, fun]; | ||
})(done); | ||
}, done); | ||
}, | ||
@@ -42,3 +50,3 @@ | ||
yield getPromise(3); | ||
})(done); | ||
}, done); | ||
}, | ||
@@ -51,3 +59,3 @@ | ||
yield gen; | ||
})(done); | ||
}, done); | ||
} | ||
@@ -54,0 +62,0 @@ }; |
1.5.1 / 2013-08-11 | ||
================== | ||
* remove setImmediate() usage - ~110% perf increase. Closes #14 | ||
0.5.0 / 2013-08-10 | ||
@@ -3,0 +8,0 @@ ================== |
22
index.js
@@ -15,5 +15,7 @@ | ||
/** | ||
* Wrap the given generator `fn`. | ||
* Wrap the given generator `fn` with | ||
* optional `done` callback. | ||
* | ||
* @param {Function} fn | ||
* @param {Function} [done] | ||
* @return {Function} | ||
@@ -23,7 +25,5 @@ * @api public | ||
function co(fn, ctx) { | ||
var args = [].slice.call(arguments, 1); | ||
var gen = isGenerator(fn) ? fn : fn.apply(this, args); | ||
function co(fn, done, ctx) { | ||
var gen = isGenerator(fn) ? fn : fn.call(this); | ||
ctx = ctx || this; | ||
var done; | ||
@@ -83,3 +83,4 @@ function next(err, res) { | ||
setImmediate(next); | ||
if (done) next(); | ||
else setImmediate(next); | ||
@@ -171,7 +172,8 @@ return function(fn){ | ||
function toThunk(obj, ctx) { | ||
if (Array.isArray(obj)) obj = exports.join.call(ctx, obj); | ||
var fn = obj; | ||
if (Array.isArray(obj)) fn = exports.join.call(ctx, obj); | ||
if (isGeneratorFunction(obj)) obj = obj.call(ctx); | ||
if (isGenerator(obj)) obj = co(obj, ctx); | ||
if (isPromise(obj)) obj = promiseToThunk(obj); | ||
return obj; | ||
if (isGenerator(obj)) fn = function(done){ co(obj, done, ctx) }; | ||
if (isPromise(obj)) fn = promiseToThunk(obj); | ||
return fn; | ||
} | ||
@@ -178,0 +180,0 @@ |
{ | ||
"name": "co", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "generator async flow control goodness", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,10 +22,3 @@ | ||
}) | ||
it('should pass arguments', function(done){ | ||
co(function *(a, b, c){ | ||
[a, b, c].should.eql([1,2,3]); | ||
done(); | ||
}, 1, 2, 3); | ||
}) | ||
describe('with no yields', function(){ | ||
@@ -32,0 +25,0 @@ it('should work', function(done){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34105
997