www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 34a2239fa1e2d765d6e63133a491c078e934049b
parent 48a8fa352bd58beb72127e5c167a4c780b7bdbb6
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  9 Jul 2012 21:01:29 -0400

Update q from upstream

Diffstat:
Mresource/q.jsm | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/resource/q.jsm b/resource/q.jsm @@ -1340,7 +1340,8 @@ function end(promise) { // If possible (that is, if in V8), transform the error stack // trace by removing Node and Q cruft, then concatenating with // the stack trace of the promise we are ``end``ing. See #57. - if (Error.captureStackTrace && "stack" in error) { + if (Error.captureStackTrace && typeof error === "object" && + "stack" in error) { var errorStackFrames = getStackFrames(error); var promiseStackFrames = getStackFrames(promise); @@ -1367,10 +1368,14 @@ function end(promise) { exports.timeout = timeout; function timeout(promise, ms) { var deferred = defer(); - when(promise, deferred.resolve, deferred.reject); - setTimeout(function () { - deferred.reject(new Error("Timed out after " + ms + "ms")); + var timeoutId = setTimeout(function () { + deferred.reject(new Error("Timed out after " + ms + " ms")); }, ms); + + when(promise, function (value) { + clearTimeout(timeoutId); + deferred.resolve(value); + }, deferred.reject); return deferred.promise; }