diff --git a/browser/bundle.js b/browser/bundle.js index 89582b70d..22c566e40 100644 --- a/browser/bundle.js +++ b/browser/bundle.js @@ -3819,7 +3819,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, @@ -4124,7 +4124,7 @@ function ensureNotHandled(reason) { function markAsOriginatingFromRejection(e) { try { - notEnumerableProp(e, "__rejectionError__", RejectionError); + notEnumerableProp(e, "isAsync", true); } catch(ignore) {} } @@ -4132,7 +4132,7 @@ function markAsOriginatingFromRejection(e) { function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof RejectionError) || - e["__rejectionError__"] === RejectionError); + e["isAsync"] === true); } function attachDefaultState(obj) { @@ -4162,6 +4162,7 @@ function canAttach(obj) { function subError(nameProperty, defaultMessage) { function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { @@ -4187,6 +4188,7 @@ function RejectionError(message) { this.name = "RejectionError"; this.message = message; this.cause = message; + this.isAsync = true; if (message instanceof Error) { this.message = message.message; @@ -5260,7 +5262,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); @@ -8230,9 +8232,7 @@ module.exports = function(Promise, INTERNAL) { ms = value; value = void 0; } - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; if (typeof caller !== "function") { caller = Promise.delay; } @@ -8265,9 +8265,7 @@ module.exports = function(Promise, INTERNAL) { }; Promise.prototype.timeout = function Promise$timeout(ms, message) { - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; var ret = new Promise(INTERNAL); ret._setTrace(this.timeout, this); @@ -8912,7 +8910,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, @@ -9745,7 +9743,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); diff --git a/js/browser/bluebird.js b/js/browser/bluebird.js index 8e01a4251..b6304c869 100644 --- a/js/browser/bluebird.js +++ b/js/browser/bluebird.js @@ -1,5 +1,5 @@ /** - * bluebird build version 1.0.0 + * bluebird build version 1.0.1 * Features enabled: core, timers, race, any, call_get, filter, generators, map, nodeify, promisify, props, reduce, settle, some, progress, cancel, synchronous_inspection */ /** @@ -584,7 +584,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, @@ -885,7 +885,7 @@ function ensureNotHandled(reason) { function markAsOriginatingFromRejection(e) { try { - notEnumerableProp(e, "__rejectionError__", RejectionError); + notEnumerableProp(e, "isAsync", true); } catch(ignore) {} } @@ -893,7 +893,7 @@ function markAsOriginatingFromRejection(e) { function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof RejectionError) || - e["__rejectionError__"] === RejectionError); + e["isAsync"] === true); } function attachDefaultState(obj) { @@ -923,6 +923,7 @@ function canAttach(obj) { function subError(nameProperty, defaultMessage) { function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { @@ -948,6 +949,7 @@ function RejectionError(message) { this.name = "RejectionError"; this.message = message; this.cause = message; + this.isAsync = true; if (message instanceof Error) { this.message = message.message; @@ -1993,7 +1995,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); @@ -4797,9 +4799,7 @@ module.exports = function(Promise, INTERNAL) { ms = value; value = void 0; } - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; if (typeof caller !== "function") { caller = Promise.delay; } @@ -4832,9 +4832,7 @@ module.exports = function(Promise, INTERNAL) { }; Promise.prototype.timeout = function Promise$timeout(ms, message) { - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; var ret = new Promise(INTERNAL); ret._setTrace(this.timeout, this); diff --git a/js/debug/captured_trace.js b/js/debug/captured_trace.js index 1c0b50b1f..161c40e05 100644 --- a/js/debug/captured_trace.js +++ b/js/debug/captured_trace.js @@ -181,7 +181,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, diff --git a/js/debug/errors.js b/js/debug/errors.js index c958bf94f..c2e7e79b5 100644 --- a/js/debug/errors.js +++ b/js/debug/errors.js @@ -59,7 +59,7 @@ function ensureNotHandled(reason) { function markAsOriginatingFromRejection(e) { try { - notEnumerableProp(e, "__rejectionError__", RejectionError); + notEnumerableProp(e, "isAsync", true); } catch(ignore) {} } @@ -67,7 +67,7 @@ function markAsOriginatingFromRejection(e) { function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof RejectionError) || - e["__rejectionError__"] === RejectionError); + e["isAsync"] === true); } function attachDefaultState(obj) { @@ -97,6 +97,7 @@ function canAttach(obj) { function subError(nameProperty, defaultMessage) { function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { @@ -122,6 +123,7 @@ function RejectionError(message) { this.name = "RejectionError"; this.message = message; this.cause = message; + this.isAsync = true; if (message instanceof Error) { this.message = message.message; diff --git a/js/debug/promise.js b/js/debug/promise.js index 0c5aa0f4f..c6c5c03cf 100644 --- a/js/debug/promise.js +++ b/js/debug/promise.js @@ -306,7 +306,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); diff --git a/js/debug/timers.js b/js/debug/timers.js index 513e2444e..04ebaf640 100644 --- a/js/debug/timers.js +++ b/js/debug/timers.js @@ -63,9 +63,7 @@ module.exports = function(Promise, INTERNAL) { ms = value; value = void 0; } - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; if (typeof caller !== "function") { caller = Promise.delay; } @@ -98,9 +96,7 @@ module.exports = function(Promise, INTERNAL) { }; Promise.prototype.timeout = function Promise$timeout(ms, message) { - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; var ret = new Promise(INTERNAL); ret._setTrace(this.timeout, this); diff --git a/js/main/captured_trace.js b/js/main/captured_trace.js index f5bd20a76..524ebb9d2 100644 --- a/js/main/captured_trace.js +++ b/js/main/captured_trace.js @@ -172,7 +172,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, diff --git a/js/main/errors.js b/js/main/errors.js index c958bf94f..c2e7e79b5 100644 --- a/js/main/errors.js +++ b/js/main/errors.js @@ -59,7 +59,7 @@ function ensureNotHandled(reason) { function markAsOriginatingFromRejection(e) { try { - notEnumerableProp(e, "__rejectionError__", RejectionError); + notEnumerableProp(e, "isAsync", true); } catch(ignore) {} } @@ -67,7 +67,7 @@ function markAsOriginatingFromRejection(e) { function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof RejectionError) || - e["__rejectionError__"] === RejectionError); + e["isAsync"] === true); } function attachDefaultState(obj) { @@ -97,6 +97,7 @@ function canAttach(obj) { function subError(nameProperty, defaultMessage) { function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { @@ -122,6 +123,7 @@ function RejectionError(message) { this.name = "RejectionError"; this.message = message; this.cause = message; + this.isAsync = true; if (message instanceof Error) { this.message = message.message; diff --git a/js/main/promise.js b/js/main/promise.js index 97ed62568..888914e62 100644 --- a/js/main/promise.js +++ b/js/main/promise.js @@ -302,7 +302,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); diff --git a/js/main/timers.js b/js/main/timers.js index 513e2444e..04ebaf640 100644 --- a/js/main/timers.js +++ b/js/main/timers.js @@ -63,9 +63,7 @@ module.exports = function(Promise, INTERNAL) { ms = value; value = void 0; } - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; if (typeof caller !== "function") { caller = Promise.delay; } @@ -98,9 +96,7 @@ module.exports = function(Promise, INTERNAL) { }; Promise.prototype.timeout = function Promise$timeout(ms, message) { - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; var ret = new Promise(INTERNAL); ret._setTrace(this.timeout, this); diff --git a/js/zalgo/captured_trace.js b/js/zalgo/captured_trace.js index f5bd20a76..524ebb9d2 100644 --- a/js/zalgo/captured_trace.js +++ b/js/zalgo/captured_trace.js @@ -172,7 +172,7 @@ var captureStackTrace = (function stackDetection() { typeof "".startsWith === "function" && (err.stack.startsWith("stackDetection@")) && stackDetection.name === "stackDetection") { - + defineProperty(Error, "stackTraceLimit", { writable: true, enumerable: false, diff --git a/js/zalgo/errors.js b/js/zalgo/errors.js index c958bf94f..c2e7e79b5 100644 --- a/js/zalgo/errors.js +++ b/js/zalgo/errors.js @@ -59,7 +59,7 @@ function ensureNotHandled(reason) { function markAsOriginatingFromRejection(e) { try { - notEnumerableProp(e, "__rejectionError__", RejectionError); + notEnumerableProp(e, "isAsync", true); } catch(ignore) {} } @@ -67,7 +67,7 @@ function markAsOriginatingFromRejection(e) { function originatesFromRejection(e) { if (e == null) return false; return ((e instanceof RejectionError) || - e["__rejectionError__"] === RejectionError); + e["isAsync"] === true); } function attachDefaultState(obj) { @@ -97,6 +97,7 @@ function canAttach(obj) { function subError(nameProperty, defaultMessage) { function SubError(message) { + if (!(this instanceof SubError)) return new SubError(message); this.message = typeof message === "string" ? message : defaultMessage; this.name = nameProperty; if (Error.captureStackTrace) { @@ -122,6 +123,7 @@ function RejectionError(message) { this.name = "RejectionError"; this.message = message; this.cause = message; + this.isAsync = true; if (message instanceof Error) { this.message = message.message; diff --git a/js/zalgo/promise.js b/js/zalgo/promise.js index 775a1e30c..6f4c0dd1c 100644 --- a/js/zalgo/promise.js +++ b/js/zalgo/promise.js @@ -302,7 +302,7 @@ Promise.method = function Promise$_Method(fn) { }; }; -Promise["try"] = Promise.attempt = function Promise$_Try(fn, args, ctx) { +Promise.attempt = Promise["try"] = function Promise$_Try(fn, args, ctx) { if (typeof fn !== "function") { return apiRejection("fn must be a function"); diff --git a/js/zalgo/timers.js b/js/zalgo/timers.js index 513e2444e..04ebaf640 100644 --- a/js/zalgo/timers.js +++ b/js/zalgo/timers.js @@ -63,9 +63,7 @@ module.exports = function(Promise, INTERNAL) { ms = value; value = void 0; } - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; if (typeof caller !== "function") { caller = Promise.delay; } @@ -98,9 +96,7 @@ module.exports = function(Promise, INTERNAL) { }; Promise.prototype.timeout = function Promise$timeout(ms, message) { - if ((ms | 0) !== ms || ms < 0) { - return apiRejection("expecting a positive integer"); - } + ms = +ms; var ret = new Promise(INTERNAL); ret._setTrace(this.timeout, this); diff --git a/package.json b/package.json index 329b7d8e5..d38407a1a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bluebird", "description": "Full featured Promises/A+ implementation with exceptionally good performance", - "version": "1.0.0", + "version": "1.0.1", "keywords": [ "promise", "performance",