Skip to content

Commit

Permalink
Bandaid for recognizing inspectable promises
Browse files Browse the repository at this point in the history
This helps but does not fix the problem of recognizing our own brand of
promises, as distinct from promises from earlier versions of Q or other
libraries (promise-alikes).
  • Loading branch information
kriskowal committed Jun 11, 2013
1 parent a649a09 commit 871a058
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,9 @@ function nearer(value) {
*/
Q.isPromise = isPromise;
function isPromise(object) {
return isObject(object) && typeof object.promiseDispatch === "function";
return isObject(object) &&
typeof object.promiseDispatch === "function" &&
typeof object.inspect === "function";
}

Q.isPromiseAlike = isPromiseAlike;
Expand Down Expand Up @@ -1379,8 +1381,10 @@ function all(promises) {
var deferred = defer();
array_reduce(promises, function (undefined, promise, index) {
var snapshot;
if (isPromise(promise) &&
(snapshot = promise.inspect()).state === "fulfilled") {
if (
isPromise(promise) &&
(snapshot = promise.inspect()).state === "fulfilled"
) {
promises[index] = snapshot.value;
} else {
++countDown;
Expand Down

0 comments on commit 871a058

Please sign in to comment.