Comparing version 4.0.2 to 4.1.0
4.1.0 / 2014-12-26 | ||
================== | ||
* fix memory leak #180 | ||
4.0.2 / 2014-12-18 | ||
@@ -3,0 +8,0 @@ ================== |
89
index.js
@@ -44,52 +44,57 @@ | ||
if (typeof gen === 'function') gen = gen.call(this); | ||
return Promise.resolve(onFulfilled()); | ||
// we wrap everything in a promise to avoid promise chaining, | ||
// which leads to memory leak errors. | ||
// see https://github.com/tj/co/issues/180 | ||
return new Promise(function(resolve, reject) { | ||
onFulfilled(); | ||
/** | ||
* @param {Mixed} res | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
/** | ||
* @param {Mixed} res | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
function onFulfilled(res) { | ||
var ret; | ||
try { | ||
ret = gen.next(res); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
function onFulfilled(res) { | ||
var ret; | ||
try { | ||
ret = gen.next(res); | ||
} catch (e) { | ||
return reject(e); | ||
} | ||
next(ret); | ||
} | ||
return next(ret); | ||
} | ||
/** | ||
* @param {Error} err | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
/** | ||
* @param {Error} err | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
function onRejected(err) { | ||
var ret; | ||
try { | ||
ret = gen.throw(err); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
function onRejected(err) { | ||
var ret; | ||
try { | ||
ret = gen.throw(err); | ||
} catch (e) { | ||
return reject(e); | ||
} | ||
next(ret); | ||
} | ||
return next(ret); | ||
} | ||
/** | ||
* Get the next value in the generator, | ||
* return a promise. | ||
* | ||
* @param {Object} ret | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
/** | ||
* Get the next value in the generator, | ||
* return a promise. | ||
* | ||
* @param {Object} ret | ||
* @return {Promise} | ||
* @api private | ||
*/ | ||
function next(ret) { | ||
if (ret.done) return Promise.resolve(ret.value); | ||
var value = toPromise.call(ctx, ret.value); | ||
if (value && isPromise(value)) return value.then(onFulfilled, onRejected); | ||
return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, ' | ||
+ 'but the following object was passed: "' + String(ret.value) + '"')); | ||
} | ||
function next(ret) { | ||
if (ret.done) return resolve(ret.value); | ||
var value = toPromise.call(ctx, ret.value); | ||
if (value && isPromise(value)) return value.then(onFulfilled, onRejected); | ||
return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, ' | ||
+ 'but the following object was passed: "' + String(ret.value) + '"')); | ||
} | ||
}); | ||
} | ||
@@ -96,0 +101,0 @@ |
{ | ||
"name": "co", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "generator async control flow goodness", | ||
@@ -16,4 +16,3 @@ "keywords": [ | ||
"mocha": "^2.0.0", | ||
"mz": "^1.0.2", | ||
"request": "^2.36.0" | ||
"mz": "^1.0.2" | ||
}, | ||
@@ -20,0 +19,0 @@ "scripts": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
14849
4
199
1