Comparing version 0.2.7 to 0.2.8
@@ -77,2 +77,6 @@ // vim:ts=4:sts=4:sw=4: | ||
var print = typeof console === "undefined" ? identity : function (message) { | ||
console.log(message); | ||
}; | ||
/** | ||
@@ -359,2 +363,21 @@ * Performs a task in a future turn of the event loop. | ||
// single call to one of the callbacks | ||
function _resolved(value) { | ||
try { | ||
return resolved ? resolved(value) : value; | ||
} catch (exception) { | ||
print(exception && exception.stack || exception); | ||
return reject(exception); | ||
} | ||
} | ||
function _rejected(reason) { | ||
try { | ||
return rejected ? rejected(reason) : reject(reason); | ||
} catch (exception) { | ||
print(exception && exception.stack || exception); | ||
return reject(exception); | ||
} | ||
} | ||
forward(ref(value), "when", function (value) { | ||
@@ -364,3 +387,3 @@ if (done) | ||
done = true; | ||
deferred.resolve(ref(value)[DUCK]("when", resolved, rejected)); | ||
deferred.resolve(ref(value)[DUCK]("when", _resolved, _rejected)); | ||
}, function (reason) { | ||
@@ -370,3 +393,3 @@ if (done) | ||
done = true; | ||
deferred.resolve(rejected ? rejected(reason) : reject(reason)); | ||
deferred.resolve(_rejected(reason)); | ||
}); | ||
@@ -502,11 +525,6 @@ return deferred.promise; | ||
*/ | ||
function forward(promise, op, resolved /* ... */) { | ||
function forward(promise /* ... */) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
enqueue(function () { | ||
try { | ||
promise[DUCK].apply(promise, args); | ||
} catch (exception) { | ||
console !== "undefined" && console.error(exception); | ||
resolved(reject(exception)); | ||
} | ||
promise[DUCK].apply(promise, args); | ||
}); | ||
@@ -513,0 +531,0 @@ } |
{ | ||
"name": "q", | ||
"description": "defer/when-style promises (CommonJS/Promises/A,B,D)", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"homepage": "http://github.com/kriskowal/q/", | ||
@@ -6,0 +6,0 @@ "author": "Kris Kowal <kris@cixar.com> (http://github.com/kriskowal/)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
87155
38
1629
551