Update Bluebird to 3.4.7
This commit is contained in:
parent
12de04607b
commit
9c0befceeb
|
@ -23,7 +23,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* bluebird build version 3.3.4
|
* bluebird build version 3.4.7
|
||||||
* Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
|
* Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
|
||||||
*/
|
*/
|
||||||
!function(e){
|
!function(e){
|
||||||
|
@ -137,6 +137,7 @@ var Queue = _dereq_("./queue");
|
||||||
var util = _dereq_("./util");
|
var util = _dereq_("./util");
|
||||||
|
|
||||||
function Async() {
|
function Async() {
|
||||||
|
this._customScheduler = false;
|
||||||
this._isTickUsed = false;
|
this._isTickUsed = false;
|
||||||
this._lateQueue = new Queue(16);
|
this._lateQueue = new Queue(16);
|
||||||
this._normalQueue = new Queue(16);
|
this._normalQueue = new Queue(16);
|
||||||
|
@ -149,6 +150,17 @@ function Async() {
|
||||||
this._schedule = schedule;
|
this._schedule = schedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Async.prototype.setScheduler = function(fn) {
|
||||||
|
var prev = this._schedule;
|
||||||
|
this._schedule = fn;
|
||||||
|
this._customScheduler = true;
|
||||||
|
return prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
Async.prototype.hasCustomScheduler = function() {
|
||||||
|
return this._customScheduler;
|
||||||
|
};
|
||||||
|
|
||||||
Async.prototype.enableTrampoline = function() {
|
Async.prototype.enableTrampoline = function() {
|
||||||
this._trampolineEnabled = true;
|
this._trampolineEnabled = true;
|
||||||
};
|
};
|
||||||
|
@ -245,11 +257,6 @@ if (!util.hasDevTools) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Async.prototype.invokeFirst = function (fn, receiver, arg) {
|
|
||||||
this._normalQueue.unshift(fn, receiver, arg);
|
|
||||||
this._queueTick();
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype._drainQueue = function(queue) {
|
Async.prototype._drainQueue = function(queue) {
|
||||||
while (queue.length() > 0) {
|
while (queue.length() > 0) {
|
||||||
var fn = queue.shift();
|
var fn = queue.shift();
|
||||||
|
@ -504,7 +511,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
||||||
|
|
||||||
var promise = this;
|
var promise = this;
|
||||||
var child = promise;
|
var child = promise;
|
||||||
while (promise.isCancellable()) {
|
while (promise._isCancellable()) {
|
||||||
if (!promise._cancelBy(child)) {
|
if (!promise._cancelBy(child)) {
|
||||||
if (child._isFollowing()) {
|
if (child._isFollowing()) {
|
||||||
child._followee().cancel();
|
child._followee().cancel();
|
||||||
|
@ -515,7 +522,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent = promise._cancellationParent;
|
var parent = promise._cancellationParent;
|
||||||
if (parent == null || !parent.isCancellable()) {
|
if (parent == null || !parent._isCancellable()) {
|
||||||
if (promise._isFollowing()) {
|
if (promise._isFollowing()) {
|
||||||
promise._followee().cancel();
|
promise._followee().cancel();
|
||||||
} else {
|
} else {
|
||||||
|
@ -524,6 +531,7 @@ Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (promise._isFollowing()) promise._followee().cancel();
|
if (promise._isFollowing()) promise._followee().cancel();
|
||||||
|
promise._setWillBeCancelled();
|
||||||
child = promise;
|
child = promise;
|
||||||
promise = parent;
|
promise = parent;
|
||||||
}
|
}
|
||||||
|
@ -561,8 +569,7 @@ Promise.prototype._cancelBranched = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.prototype._cancel = function() {
|
Promise.prototype._cancel = function() {
|
||||||
if (!this.isCancellable()) return;
|
if (!this._isCancellable()) return;
|
||||||
|
|
||||||
this._setCancelled();
|
this._setCancelled();
|
||||||
async.invoke(this._cancelPromises, this, undefined);
|
async.invoke(this._cancelPromises, this, undefined);
|
||||||
};
|
};
|
||||||
|
@ -575,6 +582,10 @@ Promise.prototype._unsetOnCancel = function() {
|
||||||
this._onCancelField = undefined;
|
this._onCancelField = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Promise.prototype._isCancellable = function() {
|
||||||
|
return this.isPending() && !this._isCancelled();
|
||||||
|
};
|
||||||
|
|
||||||
Promise.prototype.isCancellable = function() {
|
Promise.prototype.isCancellable = function() {
|
||||||
return this.isPending() && !this.isCancelled();
|
return this.isPending() && !this.isCancelled();
|
||||||
};
|
};
|
||||||
|
@ -606,7 +617,7 @@ Promise.prototype._invokeOnCancel = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.prototype._invokeInternalOnCancel = function() {
|
Promise.prototype._invokeInternalOnCancel = function() {
|
||||||
if (this.isCancellable()) {
|
if (this._isCancellable()) {
|
||||||
this._doInvokeOnCancel(this._onCancel(), true);
|
this._doInvokeOnCancel(this._onCancel(), true);
|
||||||
this._unsetOnCancel();
|
this._unsetOnCancel();
|
||||||
}
|
}
|
||||||
|
@ -745,6 +756,8 @@ var unhandledRejectionHandled;
|
||||||
var possiblyUnhandledRejection;
|
var possiblyUnhandledRejection;
|
||||||
var bluebirdFramePattern =
|
var bluebirdFramePattern =
|
||||||
/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
|
/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
|
||||||
|
var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/;
|
||||||
|
var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/;
|
||||||
var stackFramePattern = null;
|
var stackFramePattern = null;
|
||||||
var formatStack = null;
|
var formatStack = null;
|
||||||
var indentStackFrames = false;
|
var indentStackFrames = false;
|
||||||
|
@ -832,14 +845,16 @@ Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
|
||||||
Promise.onPossiblyUnhandledRejection = function (fn) {
|
Promise.onPossiblyUnhandledRejection = function (fn) {
|
||||||
var domain = getDomain();
|
var domain = getDomain();
|
||||||
possiblyUnhandledRejection =
|
possiblyUnhandledRejection =
|
||||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
typeof fn === "function" ? (domain === null ?
|
||||||
|
fn : util.domainBind(domain, fn))
|
||||||
: undefined;
|
: undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.onUnhandledRejectionHandled = function (fn) {
|
Promise.onUnhandledRejectionHandled = function (fn) {
|
||||||
var domain = getDomain();
|
var domain = getDomain();
|
||||||
unhandledRejectionHandled =
|
unhandledRejectionHandled =
|
||||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
typeof fn === "function" ? (domain === null ?
|
||||||
|
fn : util.domainBind(domain, fn))
|
||||||
: undefined;
|
: undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -875,14 +890,37 @@ Promise.hasLongStackTraces = function () {
|
||||||
|
|
||||||
var fireDomEvent = (function() {
|
var fireDomEvent = (function() {
|
||||||
try {
|
try {
|
||||||
|
if (typeof CustomEvent === "function") {
|
||||||
|
var event = new CustomEvent("CustomEvent");
|
||||||
|
util.global.dispatchEvent(event);
|
||||||
|
return function(name, event) {
|
||||||
|
var domEvent = new CustomEvent(name.toLowerCase(), {
|
||||||
|
detail: event,
|
||||||
|
cancelable: true
|
||||||
|
});
|
||||||
|
return !util.global.dispatchEvent(domEvent);
|
||||||
|
};
|
||||||
|
} else if (typeof Event === "function") {
|
||||||
|
var event = new Event("CustomEvent");
|
||||||
|
util.global.dispatchEvent(event);
|
||||||
|
return function(name, event) {
|
||||||
|
var domEvent = new Event(name.toLowerCase(), {
|
||||||
|
cancelable: true
|
||||||
|
});
|
||||||
|
domEvent.detail = event;
|
||||||
|
return !util.global.dispatchEvent(domEvent);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
var event = document.createEvent("CustomEvent");
|
var event = document.createEvent("CustomEvent");
|
||||||
event.initCustomEvent("testingtheevent", false, true, {});
|
event.initCustomEvent("testingtheevent", false, true, {});
|
||||||
util.global.dispatchEvent(event);
|
util.global.dispatchEvent(event);
|
||||||
return function(name, event) {
|
return function(name, event) {
|
||||||
var domEvent = document.createEvent("CustomEvent");
|
var domEvent = document.createEvent("CustomEvent");
|
||||||
domEvent.initCustomEvent(name.toLowerCase(), false, true, event);
|
domEvent.initCustomEvent(name.toLowerCase(), false, true,
|
||||||
|
event);
|
||||||
return !util.global.dispatchEvent(domEvent);
|
return !util.global.dispatchEvent(domEvent);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
return function() {
|
return function() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -998,6 +1036,7 @@ Promise.config = function(opts) {
|
||||||
Promise.prototype._fireEvent = defaultFireEvent;
|
Promise.prototype._fireEvent = defaultFireEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
function defaultFireEvent() { return false; }
|
function defaultFireEvent() { return false; }
|
||||||
|
@ -1039,7 +1078,7 @@ function cancellationExecute(executor, resolve, reject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancellationAttachCancellationCallback(onCancel) {
|
function cancellationAttachCancellationCallback(onCancel) {
|
||||||
if (!this.isCancellable()) return this;
|
if (!this._isCancellable()) return this;
|
||||||
|
|
||||||
var previousOnCancel = this._onCancel();
|
var previousOnCancel = this._onCancel();
|
||||||
if (previousOnCancel !== undefined) {
|
if (previousOnCancel !== undefined) {
|
||||||
|
@ -1127,12 +1166,44 @@ function checkForgottenReturns(returnValue, promiseCreated, name, promise,
|
||||||
if (returnValue === undefined && promiseCreated !== null &&
|
if (returnValue === undefined && promiseCreated !== null &&
|
||||||
wForgottenReturn) {
|
wForgottenReturn) {
|
||||||
if (parent !== undefined && parent._returnedNonUndefined()) return;
|
if (parent !== undefined && parent._returnedNonUndefined()) return;
|
||||||
var bitField = promise._bitField;
|
if ((promise._bitField & 65535) === 0) return;
|
||||||
if ((bitField & 65535) === 0) return;
|
|
||||||
|
|
||||||
if (name) name = name + " ";
|
if (name) name = name + " ";
|
||||||
|
var handlerLine = "";
|
||||||
|
var creatorLine = "";
|
||||||
|
if (promiseCreated._trace) {
|
||||||
|
var traceLines = promiseCreated._trace.stack.split("\n");
|
||||||
|
var stack = cleanStack(traceLines);
|
||||||
|
for (var i = stack.length - 1; i >= 0; --i) {
|
||||||
|
var line = stack[i];
|
||||||
|
if (!nodeFramePattern.test(line)) {
|
||||||
|
var lineMatches = line.match(parseLinePattern);
|
||||||
|
if (lineMatches) {
|
||||||
|
handlerLine = "at " + lineMatches[1] +
|
||||||
|
":" + lineMatches[2] + ":" + lineMatches[3] + " ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.length > 0) {
|
||||||
|
var firstUserLine = stack[0];
|
||||||
|
for (var i = 0; i < traceLines.length; ++i) {
|
||||||
|
|
||||||
|
if (traceLines[i] === firstUserLine) {
|
||||||
|
if (i > 0) {
|
||||||
|
creatorLine = "\n" + traceLines[i - 1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
var msg = "a promise was created in a " + name +
|
var msg = "a promise was created in a " + name +
|
||||||
"handler but was not returned from it";
|
"handler " + handlerLine + "but was not returned from it, " +
|
||||||
|
"see http://goo.gl/rRqMUw" +
|
||||||
|
creatorLine;
|
||||||
promise._warn(msg, true, promiseCreated);
|
promise._warn(msg, true, promiseCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1307,7 @@ function stackFramesAsArray(error) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0 && error.name != "SyntaxError") {
|
||||||
stack = stack.slice(i);
|
stack = stack.slice(i);
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
|
@ -1249,7 +1320,7 @@ function parseStackAndMessage(error) {
|
||||||
? stackFramesAsArray(error) : [" (No stack trace)"];
|
? stackFramesAsArray(error) : [" (No stack trace)"];
|
||||||
return {
|
return {
|
||||||
message: message,
|
message: message,
|
||||||
stack: cleanStack(stack)
|
stack: error.name == "SyntaxError" ? stack : cleanStack(stack)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1654,7 +1725,7 @@ function PromiseMapSeries(promises, fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.prototype.each = function (fn) {
|
Promise.prototype.each = function (fn) {
|
||||||
return this.mapSeries(fn)
|
return PromiseReduce(this, fn, INTERNAL, 0)
|
||||||
._then(promiseAllThis, undefined, undefined, this, undefined);
|
._then(promiseAllThis, undefined, undefined, this, undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1663,13 +1734,14 @@ Promise.prototype.mapSeries = function (fn) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.each = function (promises, fn) {
|
Promise.each = function (promises, fn) {
|
||||||
return PromiseMapSeries(promises, fn)
|
return PromiseReduce(promises, fn, INTERNAL, 0)
|
||||||
._then(promiseAllThis, undefined, undefined, promises, undefined);
|
._then(promiseAllThis, undefined, undefined, promises, undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.mapSeries = PromiseMapSeries;
|
Promise.mapSeries = PromiseMapSeries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
},{}],12:[function(_dereq_,module,exports){
|
},{}],12:[function(_dereq_,module,exports){
|
||||||
"use strict";
|
"use strict";
|
||||||
var es5 = _dereq_("./es5");
|
var es5 = _dereq_("./es5");
|
||||||
|
@ -1946,7 +2018,7 @@ function finallyHandler(reasonOrValue) {
|
||||||
var maybePromise = tryConvertToPromise(ret, promise);
|
var maybePromise = tryConvertToPromise(ret, promise);
|
||||||
if (maybePromise instanceof Promise) {
|
if (maybePromise instanceof Promise) {
|
||||||
if (this.cancelPromise != null) {
|
if (this.cancelPromise != null) {
|
||||||
if (maybePromise.isCancelled()) {
|
if (maybePromise._isCancelled()) {
|
||||||
var reason =
|
var reason =
|
||||||
new CancellationError("late cancellation observer");
|
new CancellationError("late cancellation observer");
|
||||||
promise._attachExtraTrace(reason);
|
promise._attachExtraTrace(reason);
|
||||||
|
@ -2030,9 +2102,18 @@ function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
||||||
|
if (debug.cancellation()) {
|
||||||
|
var internal = new Promise(INTERNAL);
|
||||||
|
var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
|
||||||
|
this._promise = internal.lastly(function() {
|
||||||
|
return _finallyPromise;
|
||||||
|
});
|
||||||
|
internal._captureStackTrace();
|
||||||
|
internal._setOnCancel(this);
|
||||||
|
} else {
|
||||||
var promise = this._promise = new Promise(INTERNAL);
|
var promise = this._promise = new Promise(INTERNAL);
|
||||||
promise._captureStackTrace();
|
promise._captureStackTrace();
|
||||||
promise._setOnCancel(this);
|
}
|
||||||
this._stack = stack;
|
this._stack = stack;
|
||||||
this._generatorFunction = generatorFunction;
|
this._generatorFunction = generatorFunction;
|
||||||
this._receiver = receiver;
|
this._receiver = receiver;
|
||||||
|
@ -2041,6 +2122,7 @@ function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
||||||
? [yieldHandler].concat(yieldHandlers)
|
? [yieldHandler].concat(yieldHandlers)
|
||||||
: yieldHandlers;
|
: yieldHandlers;
|
||||||
this._yieldedPromise = null;
|
this._yieldedPromise = null;
|
||||||
|
this._cancellationPhase = false;
|
||||||
}
|
}
|
||||||
util.inherits(PromiseSpawn, Proxyable);
|
util.inherits(PromiseSpawn, Proxyable);
|
||||||
|
|
||||||
|
@ -2050,6 +2132,10 @@ PromiseSpawn.prototype._isResolved = function() {
|
||||||
|
|
||||||
PromiseSpawn.prototype._cleanup = function() {
|
PromiseSpawn.prototype._cleanup = function() {
|
||||||
this._promise = this._generator = null;
|
this._promise = this._generator = null;
|
||||||
|
if (debug.cancellation() && this._finallyPromise !== null) {
|
||||||
|
this._finallyPromise._fulfill();
|
||||||
|
this._finallyPromise = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PromiseSpawn.prototype._promiseCancelled = function() {
|
PromiseSpawn.prototype._promiseCancelled = function() {
|
||||||
|
@ -2066,22 +2152,15 @@ PromiseSpawn.prototype._promiseCancelled = function() {
|
||||||
result = tryCatch(this._generator["throw"]).call(this._generator,
|
result = tryCatch(this._generator["throw"]).call(this._generator,
|
||||||
reason);
|
reason);
|
||||||
this._promise._popContext();
|
this._promise._popContext();
|
||||||
if (result === errorObj && result.e === reason) {
|
|
||||||
result = null;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this._promise._pushContext();
|
this._promise._pushContext();
|
||||||
result = tryCatch(this._generator["return"]).call(this._generator,
|
result = tryCatch(this._generator["return"]).call(this._generator,
|
||||||
undefined);
|
undefined);
|
||||||
this._promise._popContext();
|
this._promise._popContext();
|
||||||
}
|
}
|
||||||
var promise = this._promise;
|
this._cancellationPhase = true;
|
||||||
this._cleanup();
|
this._yieldedPromise = null;
|
||||||
if (result === errorObj) {
|
this._continue(result);
|
||||||
promise._rejectCallback(result.e, false);
|
|
||||||
} else {
|
|
||||||
promise.cancel();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PromiseSpawn.prototype._promiseFulfilled = function(value) {
|
PromiseSpawn.prototype._promiseFulfilled = function(value) {
|
||||||
|
@ -2106,7 +2185,6 @@ PromiseSpawn.prototype._resultCancelled = function() {
|
||||||
if (this._yieldedPromise instanceof Promise) {
|
if (this._yieldedPromise instanceof Promise) {
|
||||||
var promise = this._yieldedPromise;
|
var promise = this._yieldedPromise;
|
||||||
this._yieldedPromise = null;
|
this._yieldedPromise = null;
|
||||||
this._promiseCancelled();
|
|
||||||
promise.cancel();
|
promise.cancel();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2126,13 +2204,21 @@ PromiseSpawn.prototype._continue = function (result) {
|
||||||
var promise = this._promise;
|
var promise = this._promise;
|
||||||
if (result === errorObj) {
|
if (result === errorObj) {
|
||||||
this._cleanup();
|
this._cleanup();
|
||||||
|
if (this._cancellationPhase) {
|
||||||
|
return promise.cancel();
|
||||||
|
} else {
|
||||||
return promise._rejectCallback(result.e, false);
|
return promise._rejectCallback(result.e, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var value = result.value;
|
var value = result.value;
|
||||||
if (result.done === true) {
|
if (result.done === true) {
|
||||||
this._cleanup();
|
this._cleanup();
|
||||||
|
if (this._cancellationPhase) {
|
||||||
|
return promise.cancel();
|
||||||
|
} else {
|
||||||
return promise._resolveCallback(value);
|
return promise._resolveCallback(value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var maybePromise = tryConvertToPromise(value, this._promise);
|
var maybePromise = tryConvertToPromise(value, this._promise);
|
||||||
if (!(maybePromise instanceof Promise)) {
|
if (!(maybePromise instanceof Promise)) {
|
||||||
|
@ -2158,9 +2244,13 @@ PromiseSpawn.prototype._continue = function (result) {
|
||||||
this._yieldedPromise = maybePromise;
|
this._yieldedPromise = maybePromise;
|
||||||
maybePromise._proxy(this, null);
|
maybePromise._proxy(this, null);
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
} else if (((bitField & 33554432) !== 0)) {
|
||||||
this._promiseFulfilled(maybePromise._value());
|
Promise._async.invoke(
|
||||||
|
this._promiseFulfilled, this, maybePromise._value()
|
||||||
|
);
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
} else if (((bitField & 16777216) !== 0)) {
|
||||||
this._promiseRejected(maybePromise._reason());
|
Promise._async.invoke(
|
||||||
|
this._promiseRejected, this, maybePromise._reason()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this._promiseCancelled();
|
this._promiseCancelled();
|
||||||
}
|
}
|
||||||
|
@ -2207,7 +2297,8 @@ Promise.spawn = function (generatorFunction) {
|
||||||
},{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
|
},{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports =
|
module.exports =
|
||||||
function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
|
function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async,
|
||||||
|
getDomain) {
|
||||||
var util = _dereq_("./util");
|
var util = _dereq_("./util");
|
||||||
var canEvaluate = util.canEvaluate;
|
var canEvaluate = util.canEvaluate;
|
||||||
var tryCatch = util.tryCatch;
|
var tryCatch = util.tryCatch;
|
||||||
|
@ -2249,25 +2340,35 @@ if (canEvaluate) {
|
||||||
var name = "Holder$" + total;
|
var name = "Holder$" + total;
|
||||||
|
|
||||||
|
|
||||||
var code = "return function(tryCatch, errorObj, Promise) { \n\
|
var code = "return function(tryCatch, errorObj, Promise, async) { \n\
|
||||||
'use strict'; \n\
|
'use strict'; \n\
|
||||||
function [TheName](fn) { \n\
|
function [TheName](fn) { \n\
|
||||||
[TheProperties] \n\
|
[TheProperties] \n\
|
||||||
this.fn = fn; \n\
|
this.fn = fn; \n\
|
||||||
|
this.asyncNeeded = true; \n\
|
||||||
this.now = 0; \n\
|
this.now = 0; \n\
|
||||||
} \n\
|
} \n\
|
||||||
[TheName].prototype.checkFulfillment = function(promise) { \n\
|
\n\
|
||||||
var now = ++this.now; \n\
|
[TheName].prototype._callFunction = function(promise) { \n\
|
||||||
if (now === [TheTotal]) { \n\
|
|
||||||
promise._pushContext(); \n\
|
promise._pushContext(); \n\
|
||||||
var callback = this.fn; \n\
|
var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
|
||||||
var ret = tryCatch(callback)([ThePassedArguments]); \n\
|
|
||||||
promise._popContext(); \n\
|
promise._popContext(); \n\
|
||||||
if (ret === errorObj) { \n\
|
if (ret === errorObj) { \n\
|
||||||
promise._rejectCallback(ret.e, false); \n\
|
promise._rejectCallback(ret.e, false); \n\
|
||||||
} else { \n\
|
} else { \n\
|
||||||
promise._resolveCallback(ret); \n\
|
promise._resolveCallback(ret); \n\
|
||||||
} \n\
|
} \n\
|
||||||
|
}; \n\
|
||||||
|
\n\
|
||||||
|
[TheName].prototype.checkFulfillment = function(promise) { \n\
|
||||||
|
var now = ++this.now; \n\
|
||||||
|
if (now === [TheTotal]) { \n\
|
||||||
|
if (this.asyncNeeded) { \n\
|
||||||
|
async.invoke(this._callFunction, this, promise); \n\
|
||||||
|
} else { \n\
|
||||||
|
this._callFunction(promise); \n\
|
||||||
|
} \n\
|
||||||
|
\n\
|
||||||
} \n\
|
} \n\
|
||||||
}; \n\
|
}; \n\
|
||||||
\n\
|
\n\
|
||||||
|
@ -2276,7 +2377,7 @@ if (canEvaluate) {
|
||||||
}; \n\
|
}; \n\
|
||||||
\n\
|
\n\
|
||||||
return [TheName]; \n\
|
return [TheName]; \n\
|
||||||
}(tryCatch, errorObj, Promise); \n\
|
}(tryCatch, errorObj, Promise, async); \n\
|
||||||
";
|
";
|
||||||
|
|
||||||
code = code.replace(/\[TheName\]/g, name)
|
code = code.replace(/\[TheName\]/g, name)
|
||||||
|
@ -2285,8 +2386,8 @@ if (canEvaluate) {
|
||||||
.replace(/\[TheProperties\]/g, assignment)
|
.replace(/\[TheProperties\]/g, assignment)
|
||||||
.replace(/\[CancellationCode\]/g, cancellationCode);
|
.replace(/\[CancellationCode\]/g, cancellationCode);
|
||||||
|
|
||||||
return new Function("tryCatch", "errorObj", "Promise", code)
|
return new Function("tryCatch", "errorObj", "Promise", "async", code)
|
||||||
(tryCatch, errorObj, Promise);
|
(tryCatch, errorObj, Promise, async);
|
||||||
};
|
};
|
||||||
|
|
||||||
var holderClasses = [];
|
var holderClasses = [];
|
||||||
|
@ -2327,6 +2428,7 @@ Promise.join = function () {
|
||||||
maybePromise._then(callbacks[i], reject,
|
maybePromise._then(callbacks[i], reject,
|
||||||
undefined, ret, holder);
|
undefined, ret, holder);
|
||||||
promiseSetters[i](maybePromise, holder);
|
promiseSetters[i](maybePromise, holder);
|
||||||
|
holder.asyncNeeded = false;
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
} else if (((bitField & 33554432) !== 0)) {
|
||||||
callbacks[i].call(ret,
|
callbacks[i].call(ret,
|
||||||
maybePromise._value(), holder);
|
maybePromise._value(), holder);
|
||||||
|
@ -2339,7 +2441,14 @@ Promise.join = function () {
|
||||||
callbacks[i].call(ret, maybePromise, holder);
|
callbacks[i].call(ret, maybePromise, holder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret._isFateSealed()) {
|
if (!ret._isFateSealed()) {
|
||||||
|
if (holder.asyncNeeded) {
|
||||||
|
var domain = getDomain();
|
||||||
|
if (domain !== null) {
|
||||||
|
holder.fn = util.domainBind(domain, holder.fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
ret._setAsyncGuaranteed();
|
ret._setAsyncGuaranteed();
|
||||||
ret._setOnCancel(holder);
|
ret._setOnCancel(holder);
|
||||||
}
|
}
|
||||||
|
@ -2367,23 +2476,27 @@ var getDomain = Promise._getDomain;
|
||||||
var util = _dereq_("./util");
|
var util = _dereq_("./util");
|
||||||
var tryCatch = util.tryCatch;
|
var tryCatch = util.tryCatch;
|
||||||
var errorObj = util.errorObj;
|
var errorObj = util.errorObj;
|
||||||
var EMPTY_ARRAY = [];
|
var async = Promise._async;
|
||||||
|
|
||||||
function MappingPromiseArray(promises, fn, limit, _filter) {
|
function MappingPromiseArray(promises, fn, limit, _filter) {
|
||||||
this.constructor$(promises);
|
this.constructor$(promises);
|
||||||
this._promise._captureStackTrace();
|
this._promise._captureStackTrace();
|
||||||
var domain = getDomain();
|
var domain = getDomain();
|
||||||
this._callback = domain === null ? fn : domain.bind(fn);
|
this._callback = domain === null ? fn : util.domainBind(domain, fn);
|
||||||
this._preservedValues = _filter === INTERNAL
|
this._preservedValues = _filter === INTERNAL
|
||||||
? new Array(this.length())
|
? new Array(this.length())
|
||||||
: null;
|
: null;
|
||||||
this._limit = limit;
|
this._limit = limit;
|
||||||
this._inFlight = 0;
|
this._inFlight = 0;
|
||||||
this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
|
this._queue = [];
|
||||||
this._init$(undefined, -2);
|
async.invoke(this._asyncInit, this, undefined);
|
||||||
}
|
}
|
||||||
util.inherits(MappingPromiseArray, PromiseArray);
|
util.inherits(MappingPromiseArray, PromiseArray);
|
||||||
|
|
||||||
|
MappingPromiseArray.prototype._asyncInit = function() {
|
||||||
|
this._init$(undefined, -2);
|
||||||
|
};
|
||||||
|
|
||||||
MappingPromiseArray.prototype._init = function () {};
|
MappingPromiseArray.prototype._init = function () {};
|
||||||
|
|
||||||
MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||||
|
@ -2489,9 +2602,22 @@ function map(promises, fn, options, _filter) {
|
||||||
if (typeof fn !== "function") {
|
if (typeof fn !== "function") {
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||||
}
|
}
|
||||||
var limit = typeof options === "object" && options !== null
|
|
||||||
? options.concurrency
|
var limit = 0;
|
||||||
: 0;
|
if (options !== undefined) {
|
||||||
|
if (typeof options === "object" && options !== null) {
|
||||||
|
if (typeof options.concurrency !== "number") {
|
||||||
|
return Promise.reject(
|
||||||
|
new TypeError("'concurrency' must be a number but it is " +
|
||||||
|
util.classString(options.concurrency)));
|
||||||
|
}
|
||||||
|
limit = options.concurrency;
|
||||||
|
} else {
|
||||||
|
return Promise.reject(new TypeError(
|
||||||
|
"options argument must be an object but it is " +
|
||||||
|
util.classString(options)));
|
||||||
|
}
|
||||||
|
}
|
||||||
limit = typeof limit === "number" &&
|
limit = typeof limit === "number" &&
|
||||||
isFinite(limit) && limit >= 1 ? limit : 0;
|
isFinite(limit) && limit >= 1 ? limit : 0;
|
||||||
return new MappingPromiseArray(promises, fn, limit, _filter).promise();
|
return new MappingPromiseArray(promises, fn, limit, _filter).promise();
|
||||||
|
@ -2775,7 +2901,8 @@ Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
||||||
if (util.isObject(item)) {
|
if (util.isObject(item)) {
|
||||||
catchInstances[j++] = item;
|
catchInstances[j++] = item;
|
||||||
} else {
|
} else {
|
||||||
return apiRejection("expecting an object but got " + util.classString(item));
|
return apiRejection("expecting an object but got " +
|
||||||
|
"A catch statement predicate " + util.classString(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catchInstances.length = j;
|
catchInstances.length = j;
|
||||||
|
@ -2845,6 +2972,8 @@ Promise.prototype.error = function (fn) {
|
||||||
return this.caught(util.originatesFromRejection, fn);
|
return this.caught(util.originatesFromRejection, fn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Promise.getNewLibraryCopy = module.exports;
|
||||||
|
|
||||||
Promise.is = function (val) {
|
Promise.is = function (val) {
|
||||||
return val instanceof Promise;
|
return val instanceof Promise;
|
||||||
};
|
};
|
||||||
|
@ -2890,9 +3019,7 @@ Promise.setScheduler = function(fn) {
|
||||||
if (typeof fn !== "function") {
|
if (typeof fn !== "function") {
|
||||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
throw new TypeError("expecting a function but got " + util.classString(fn));
|
||||||
}
|
}
|
||||||
var prev = async._schedule;
|
return async.setScheduler(fn);
|
||||||
async._schedule = fn;
|
|
||||||
return prev;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.prototype._then = function (
|
Promise.prototype._then = function (
|
||||||
|
@ -2939,7 +3066,8 @@ Promise.prototype._then = function (
|
||||||
|
|
||||||
async.invoke(settler, target, {
|
async.invoke(settler, target, {
|
||||||
handler: domain === null ? handler
|
handler: domain === null ? handler
|
||||||
: (typeof handler === "function" && domain.bind(handler)),
|
: (typeof handler === "function" &&
|
||||||
|
util.domainBind(domain, handler)),
|
||||||
promise: promise,
|
promise: promise,
|
||||||
receiver: receiver,
|
receiver: receiver,
|
||||||
value: value
|
value: value
|
||||||
|
@ -3000,7 +3128,12 @@ Promise.prototype._setCancelled = function() {
|
||||||
this._fireEvent("promiseCancelled", this);
|
this._fireEvent("promiseCancelled", this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Promise.prototype._setWillBeCancelled = function() {
|
||||||
|
this._bitField = this._bitField | 8388608;
|
||||||
|
};
|
||||||
|
|
||||||
Promise.prototype._setAsyncGuaranteed = function() {
|
Promise.prototype._setAsyncGuaranteed = function() {
|
||||||
|
if (async.hasCustomScheduler()) return;
|
||||||
this._bitField = this._bitField | 134217728;
|
this._bitField = this._bitField | 134217728;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3070,11 +3203,11 @@ Promise.prototype._addCallbacks = function (
|
||||||
this._receiver0 = receiver;
|
this._receiver0 = receiver;
|
||||||
if (typeof fulfill === "function") {
|
if (typeof fulfill === "function") {
|
||||||
this._fulfillmentHandler0 =
|
this._fulfillmentHandler0 =
|
||||||
domain === null ? fulfill : domain.bind(fulfill);
|
domain === null ? fulfill : util.domainBind(domain, fulfill);
|
||||||
}
|
}
|
||||||
if (typeof reject === "function") {
|
if (typeof reject === "function") {
|
||||||
this._rejectionHandler0 =
|
this._rejectionHandler0 =
|
||||||
domain === null ? reject : domain.bind(reject);
|
domain === null ? reject : util.domainBind(domain, reject);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var base = index * 4 - 4;
|
var base = index * 4 - 4;
|
||||||
|
@ -3082,11 +3215,11 @@ Promise.prototype._addCallbacks = function (
|
||||||
this[base + 3] = receiver;
|
this[base + 3] = receiver;
|
||||||
if (typeof fulfill === "function") {
|
if (typeof fulfill === "function") {
|
||||||
this[base + 0] =
|
this[base + 0] =
|
||||||
domain === null ? fulfill : domain.bind(fulfill);
|
domain === null ? fulfill : util.domainBind(domain, fulfill);
|
||||||
}
|
}
|
||||||
if (typeof reject === "function") {
|
if (typeof reject === "function") {
|
||||||
this[base + 1] =
|
this[base + 1] =
|
||||||
domain === null ? reject : domain.bind(reject);
|
domain === null ? reject : util.domainBind(domain, reject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._setLength(index + 1);
|
this._setLength(index + 1);
|
||||||
|
@ -3403,23 +3536,24 @@ _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug);
|
||||||
_dereq_("./direct_resolve")(Promise);
|
_dereq_("./direct_resolve")(Promise);
|
||||||
_dereq_("./synchronous_inspection")(Promise);
|
_dereq_("./synchronous_inspection")(Promise);
|
||||||
_dereq_("./join")(
|
_dereq_("./join")(
|
||||||
Promise, PromiseArray, tryConvertToPromise, INTERNAL, debug);
|
Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain);
|
||||||
Promise.Promise = Promise;
|
Promise.Promise = Promise;
|
||||||
|
Promise.version = "3.4.7";
|
||||||
_dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
_dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||||
|
_dereq_('./call_get.js')(Promise);
|
||||||
_dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
_dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
||||||
_dereq_('./timers.js')(Promise, INTERNAL, debug);
|
_dereq_('./timers.js')(Promise, INTERNAL, debug);
|
||||||
_dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
_dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
||||||
_dereq_('./nodeify.js')(Promise);
|
_dereq_('./nodeify.js')(Promise);
|
||||||
_dereq_('./call_get.js')(Promise);
|
_dereq_('./promisify.js')(Promise, INTERNAL);
|
||||||
_dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
_dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
||||||
_dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
_dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
||||||
_dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
_dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||||
_dereq_('./settle.js')(Promise, PromiseArray, debug);
|
_dereq_('./settle.js')(Promise, PromiseArray, debug);
|
||||||
_dereq_('./some.js')(Promise, PromiseArray, apiRejection);
|
_dereq_('./some.js')(Promise, PromiseArray, apiRejection);
|
||||||
_dereq_('./promisify.js')(Promise, INTERNAL);
|
|
||||||
_dereq_('./any.js')(Promise);
|
|
||||||
_dereq_('./each.js')(Promise, INTERNAL);
|
|
||||||
_dereq_('./filter.js')(Promise, INTERNAL);
|
_dereq_('./filter.js')(Promise, INTERNAL);
|
||||||
|
_dereq_('./each.js')(Promise, INTERNAL);
|
||||||
|
_dereq_('./any.js')(Promise);
|
||||||
|
|
||||||
util.toFastProperties(Promise);
|
util.toFastProperties(Promise);
|
||||||
util.toFastProperties(Promise.prototype);
|
util.toFastProperties(Promise.prototype);
|
||||||
|
@ -3574,7 +3708,7 @@ PromiseArray.prototype._resolve = function (value) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PromiseArray.prototype._cancel = function() {
|
PromiseArray.prototype._cancel = function() {
|
||||||
if (this._isResolved() || !this._promise.isCancellable()) return;
|
if (this._isResolved() || !this._promise._isCancellable()) return;
|
||||||
this._values = null;
|
this._values = null;
|
||||||
this._promise._cancel();
|
this._promise._cancel();
|
||||||
};
|
};
|
||||||
|
@ -4094,23 +4228,6 @@ Queue.prototype._pushOne = function (arg) {
|
||||||
this._length = length + 1;
|
this._length = length + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Queue.prototype._unshiftOne = function(value) {
|
|
||||||
var capacity = this._capacity;
|
|
||||||
this._checkCapacity(this.length() + 1);
|
|
||||||
var front = this._front;
|
|
||||||
var i = (((( front - 1 ) &
|
|
||||||
( capacity - 1) ) ^ capacity ) - capacity );
|
|
||||||
this[i] = value;
|
|
||||||
this._front = i;
|
|
||||||
this._length = this.length() + 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.unshift = function(fn, receiver, arg) {
|
|
||||||
this._unshiftOne(arg);
|
|
||||||
this._unshiftOne(receiver);
|
|
||||||
this._unshiftOne(fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.push = function (fn, receiver, arg) {
|
Queue.prototype.push = function (fn, receiver, arg) {
|
||||||
var length = this.length() + 3;
|
var length = this.length() + 3;
|
||||||
if (this._willBeOverCapacity(length)) {
|
if (this._willBeOverCapacity(length)) {
|
||||||
|
@ -4225,27 +4342,37 @@ var tryCatch = util.tryCatch;
|
||||||
function ReductionPromiseArray(promises, fn, initialValue, _each) {
|
function ReductionPromiseArray(promises, fn, initialValue, _each) {
|
||||||
this.constructor$(promises);
|
this.constructor$(promises);
|
||||||
var domain = getDomain();
|
var domain = getDomain();
|
||||||
this._fn = domain === null ? fn : domain.bind(fn);
|
this._fn = domain === null ? fn : util.domainBind(domain, fn);
|
||||||
if (initialValue !== undefined) {
|
if (initialValue !== undefined) {
|
||||||
initialValue = Promise.resolve(initialValue);
|
initialValue = Promise.resolve(initialValue);
|
||||||
initialValue._attachCancellationCallback(this);
|
initialValue._attachCancellationCallback(this);
|
||||||
}
|
}
|
||||||
this._initialValue = initialValue;
|
this._initialValue = initialValue;
|
||||||
this._currentCancellable = null;
|
this._currentCancellable = null;
|
||||||
this._eachValues = _each === INTERNAL ? [] : undefined;
|
if(_each === INTERNAL) {
|
||||||
|
this._eachValues = Array(this._length);
|
||||||
|
} else if (_each === 0) {
|
||||||
|
this._eachValues = null;
|
||||||
|
} else {
|
||||||
|
this._eachValues = undefined;
|
||||||
|
}
|
||||||
this._promise._captureStackTrace();
|
this._promise._captureStackTrace();
|
||||||
this._init$(undefined, -5);
|
this._init$(undefined, -5);
|
||||||
}
|
}
|
||||||
util.inherits(ReductionPromiseArray, PromiseArray);
|
util.inherits(ReductionPromiseArray, PromiseArray);
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._gotAccum = function(accum) {
|
ReductionPromiseArray.prototype._gotAccum = function(accum) {
|
||||||
if (this._eachValues !== undefined && accum !== INTERNAL) {
|
if (this._eachValues !== undefined &&
|
||||||
|
this._eachValues !== null &&
|
||||||
|
accum !== INTERNAL) {
|
||||||
this._eachValues.push(accum);
|
this._eachValues.push(accum);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._eachComplete = function(value) {
|
ReductionPromiseArray.prototype._eachComplete = function(value) {
|
||||||
|
if (this._eachValues !== null) {
|
||||||
this._eachValues.push(value);
|
this._eachValues.push(value);
|
||||||
|
}
|
||||||
return this._eachValues;
|
return this._eachValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4381,16 +4508,23 @@ var schedule;
|
||||||
var noAsyncScheduler = function() {
|
var noAsyncScheduler = function() {
|
||||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||||
};
|
};
|
||||||
|
var NativePromise = util.getNativePromise();
|
||||||
if (util.isNode && typeof MutationObserver === "undefined") {
|
if (util.isNode && typeof MutationObserver === "undefined") {
|
||||||
var GlobalSetImmediate = global.setImmediate;
|
var GlobalSetImmediate = global.setImmediate;
|
||||||
var ProcessNextTick = process.nextTick;
|
var ProcessNextTick = process.nextTick;
|
||||||
schedule = util.isRecentNode
|
schedule = util.isRecentNode
|
||||||
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
||||||
: function(fn) { ProcessNextTick.call(process, fn); };
|
: function(fn) { ProcessNextTick.call(process, fn); };
|
||||||
|
} else if (typeof NativePromise === "function" &&
|
||||||
|
typeof NativePromise.resolve === "function") {
|
||||||
|
var nativePromise = NativePromise.resolve();
|
||||||
|
schedule = function(fn) {
|
||||||
|
nativePromise.then(fn);
|
||||||
|
};
|
||||||
} else if ((typeof MutationObserver !== "undefined") &&
|
} else if ((typeof MutationObserver !== "undefined") &&
|
||||||
!(typeof window !== "undefined" &&
|
!(typeof window !== "undefined" &&
|
||||||
window.navigator &&
|
window.navigator &&
|
||||||
window.navigator.standalone)) {
|
(window.navigator.standalone || window.cordova))) {
|
||||||
schedule = (function() {
|
schedule = (function() {
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
var opts = {attributes: true};
|
var opts = {attributes: true};
|
||||||
|
@ -4676,13 +4810,20 @@ var isResolved = PromiseInspection.prototype.isResolved = function () {
|
||||||
return (this._bitField & 50331648) !== 0;
|
return (this._bitField & 50331648) !== 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
PromiseInspection.prototype.isCancelled =
|
PromiseInspection.prototype.isCancelled = function() {
|
||||||
Promise.prototype._isCancelled = function() {
|
return (this._bitField & 8454144) !== 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.prototype.__isCancelled = function() {
|
||||||
return (this._bitField & 65536) === 65536;
|
return (this._bitField & 65536) === 65536;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Promise.prototype._isCancelled = function() {
|
||||||
|
return this._target().__isCancelled();
|
||||||
|
};
|
||||||
|
|
||||||
Promise.prototype.isCancelled = function() {
|
Promise.prototype.isCancelled = function() {
|
||||||
return this._target()._isCancelled();
|
return (this._target()._bitField & 8454144) !== 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.prototype.isPending = function() {
|
Promise.prototype.isPending = function() {
|
||||||
|
@ -4772,7 +4913,11 @@ function getThen(obj) {
|
||||||
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
var hasProp = {}.hasOwnProperty;
|
||||||
function isAnyBluebirdPromise(obj) {
|
function isAnyBluebirdPromise(obj) {
|
||||||
|
try {
|
||||||
return hasProp.call(obj, "_promise0");
|
return hasProp.call(obj, "_promise0");
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function doThenable(x, then, context) {
|
function doThenable(x, then, context) {
|
||||||
|
@ -4837,6 +4982,7 @@ var delay = Promise.delay = function (ms, value) {
|
||||||
if (debug.cancellation()) {
|
if (debug.cancellation()) {
|
||||||
ret._setOnCancel(new HandleWrapper(handle));
|
ret._setOnCancel(new HandleWrapper(handle));
|
||||||
}
|
}
|
||||||
|
ret._captureStackTrace();
|
||||||
}
|
}
|
||||||
ret._setAsyncGuaranteed();
|
ret._setAsyncGuaranteed();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -4910,6 +5056,7 @@ module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
||||||
var inherits = _dereq_("./util").inherits;
|
var inherits = _dereq_("./util").inherits;
|
||||||
var errorObj = util.errorObj;
|
var errorObj = util.errorObj;
|
||||||
var tryCatch = util.tryCatch;
|
var tryCatch = util.tryCatch;
|
||||||
|
var NULL = {};
|
||||||
|
|
||||||
function thrower(e) {
|
function thrower(e) {
|
||||||
setTimeout(function(){throw e;}, 0);
|
setTimeout(function(){throw e;}, 0);
|
||||||
|
@ -4970,14 +5117,14 @@ module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
||||||
if (this.promise().isFulfilled()) {
|
if (this.promise().isFulfilled()) {
|
||||||
return this.promise().value();
|
return this.promise().value();
|
||||||
}
|
}
|
||||||
return null;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
Disposer.prototype.tryDispose = function(inspection) {
|
Disposer.prototype.tryDispose = function(inspection) {
|
||||||
var resource = this.resource();
|
var resource = this.resource();
|
||||||
var context = this._context;
|
var context = this._context;
|
||||||
if (context !== undefined) context._pushContext();
|
if (context !== undefined) context._pushContext();
|
||||||
var ret = resource !== null
|
var ret = resource !== NULL
|
||||||
? this.doDispose(resource, inspection) : null;
|
? this.doDispose(resource, inspection) : null;
|
||||||
if (context !== undefined) context._popContext();
|
if (context !== undefined) context._popContext();
|
||||||
this._promise._unsetDisposable();
|
this._promise._unsetDisposable();
|
||||||
|
@ -5329,7 +5476,7 @@ function toFastProperties(obj) {
|
||||||
var l = 8;
|
var l = 8;
|
||||||
while (l--) new FakeConstructor();
|
while (l--) new FakeConstructor();
|
||||||
return obj;
|
return obj;
|
||||||
eval(obj);
|
//eval(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
||||||
|
@ -5441,8 +5588,26 @@ if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
||||||
var isNode = typeof process !== "undefined" &&
|
var isNode = typeof process !== "undefined" &&
|
||||||
classString(process).toLowerCase() === "[object process]";
|
classString(process).toLowerCase() === "[object process]";
|
||||||
|
|
||||||
function env(key, def) {
|
var hasEnvVariables = typeof process !== "undefined" &&
|
||||||
return isNode ? process.env[key] : def;
|
typeof process.env !== "undefined";
|
||||||
|
|
||||||
|
function env(key) {
|
||||||
|
return hasEnvVariables ? process.env[key] : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNativePromise() {
|
||||||
|
if (typeof Promise === "function") {
|
||||||
|
try {
|
||||||
|
var promise = new Promise(function(){});
|
||||||
|
if ({}.toString.call(promise) === "[object Promise]") {
|
||||||
|
return Promise;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function domainBind(self, cb) {
|
||||||
|
return self.bind(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = {
|
var ret = {
|
||||||
|
@ -5475,8 +5640,11 @@ var ret = {
|
||||||
hasDevTools: typeof chrome !== "undefined" && chrome &&
|
hasDevTools: typeof chrome !== "undefined" && chrome &&
|
||||||
typeof chrome.loadTimes === "function",
|
typeof chrome.loadTimes === "function",
|
||||||
isNode: isNode,
|
isNode: isNode,
|
||||||
|
hasEnvVariables: hasEnvVariables,
|
||||||
env: env,
|
env: env,
|
||||||
global: globalObject
|
global: globalObject,
|
||||||
|
getNativePromise: getNativePromise,
|
||||||
|
domainBind: domainBind
|
||||||
};
|
};
|
||||||
ret.isRecentNode = ret.isNode && (function() {
|
ret.isRecentNode = ret.isNode && (function() {
|
||||||
var version = process.versions.node.split(".").map(Number);
|
var version = process.versions.node.split(".").map(Number);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user