summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js')
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js647
1 files changed, 201 insertions, 446 deletions
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js
index a529187a9..ddd6a8a26 100644
--- a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js
@@ -8,7 +8,7 @@
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:</p>
+ * furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
@@ -23,7 +23,7 @@
*
*/
/**
- * bluebird build version 2.9.27
+ * bluebird build version 2.9.34
* Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, cancel, using, filter, any, each, timers
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
@@ -94,8 +94,6 @@ Async.prototype.throwLater = function(fn, arg) {
arg = fn;
fn = function () { throw arg; };
}
- var domain = this._getDomain();
- if (domain !== undefined) fn = domain.bind(fn);
if (typeof setTimeout !== "undefined") {
setTimeout(function() {
fn(arg);
@@ -109,73 +107,18 @@ Async.prototype.throwLater = function(fn, arg) {
}
};
-Async.prototype._getDomain = function() {};
-
-if (!true) {
-if (util.isNode) {
- var EventsModule = _dereq_("events");
-
- var domainGetter = function() {
- var domain = process.domain;
- if (domain === null) return undefined;
- return domain;
- };
-
- if (EventsModule.usingDomains) {
- Async.prototype._getDomain = domainGetter;
- } else {
- var descriptor =
- Object.getOwnPropertyDescriptor(EventsModule, "usingDomains");
-
- if (descriptor) {
- if (!descriptor.configurable) {
- process.on("domainsActivated", function() {
- Async.prototype._getDomain = domainGetter;
- });
- } else {
- var usingDomains = false;
- Object.defineProperty(EventsModule, "usingDomains", {
- configurable: false,
- enumerable: true,
- get: function() {
- return usingDomains;
- },
- set: function(value) {
- if (usingDomains || !value) return;
- usingDomains = true;
- Async.prototype._getDomain = domainGetter;
- util.toFastProperties(process);
- process.emit("domainsActivated");
- }
- });
- }
- }
- }
-}
-}
-
function AsyncInvokeLater(fn, receiver, arg) {
- var domain = this._getDomain();
- if (domain !== undefined) fn = domain.bind(fn);
this._lateQueue.push(fn, receiver, arg);
this._queueTick();
}
function AsyncInvoke(fn, receiver, arg) {
- var domain = this._getDomain();
- if (domain !== undefined) fn = domain.bind(fn);
this._normalQueue.push(fn, receiver, arg);
this._queueTick();
}
function AsyncSettlePromises(promise) {
- var domain = this._getDomain();
- if (domain !== undefined) {
- var fn = domain.bind(promise._settlePromises);
- this._normalQueue.push(fn, promise, undefined);
- } else {
- this._normalQueue._pushOne(promise);
- }
+ this._normalQueue._pushOne(promise);
this._queueTick();
}
@@ -184,13 +127,18 @@ if (!util.hasDevTools) {
Async.prototype.invoke = AsyncInvoke;
Async.prototype.settlePromises = AsyncSettlePromises;
} else {
+ if (schedule.isStatic) {
+ schedule = function(fn) { setTimeout(fn, 0); };
+ }
Async.prototype.invokeLater = function (fn, receiver, arg) {
if (this._trampolineEnabled) {
AsyncInvokeLater.call(this, fn, receiver, arg);
} else {
- setTimeout(function() {
- fn.call(receiver, arg);
- }, 100);
+ this._schedule(function() {
+ setTimeout(function() {
+ fn.call(receiver, arg);
+ }, 100);
+ });
}
};
@@ -198,9 +146,9 @@ if (!util.hasDevTools) {
if (this._trampolineEnabled) {
AsyncInvoke.call(this, fn, receiver, arg);
} else {
- setTimeout(function() {
+ this._schedule(function() {
fn.call(receiver, arg);
- }, 0);
+ });
}
};
@@ -208,16 +156,14 @@ if (!util.hasDevTools) {
if (this._trampolineEnabled) {
AsyncSettlePromises.call(this, promise);
} else {
- setTimeout(function() {
+ this._schedule(function() {
promise._settlePromises();
- }, 0);
+ });
}
};
}
Async.prototype.invokeFirst = function (fn, receiver, arg) {
- var domain = this._getDomain();
- if (domain !== undefined) fn = domain.bind(fn);
this._normalQueue.unshift(fn, receiver, arg);
this._queueTick();
};
@@ -255,7 +201,7 @@ Async.prototype._reset = function () {
module.exports = new Async();
module.exports.firstLineError = firstLineError;
-},{"./queue.js":28,"./schedule.js":31,"./util.js":38,"events":39}],3:[function(_dereq_,module,exports){
+},{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(_dereq_,module,exports){
"use strict";
module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
var rejectThis = function(_, e) {
@@ -268,7 +214,6 @@ var targetRejected = function(e, context) {
};
var bindingResolved = function(thisArg, context) {
- this._setBoundTo(thisArg);
if (this._isPending()) {
this._resolveCallback(context.target);
}
@@ -283,6 +228,8 @@ Promise.prototype.bind = function (thisArg) {
var ret = new Promise(INTERNAL);
ret._propagateFrom(this, 1);
var target = this._target();
+
+ ret._setBoundTo(maybePromise);
if (maybePromise instanceof Promise) {
var context = {
promiseRejectionQueued: false,
@@ -294,7 +241,6 @@ Promise.prototype.bind = function (thisArg) {
maybePromise._then(
bindingResolved, bindingRejected, ret._progress, ret, context);
} else {
- ret._setBoundTo(thisArg);
ret._resolveCallback(target);
}
return ret;
@@ -317,13 +263,12 @@ Promise.bind = function (thisArg, value) {
var maybePromise = tryConvertToPromise(thisArg);
var ret = new Promise(INTERNAL);
+ ret._setBoundTo(maybePromise);
if (maybePromise instanceof Promise) {
- maybePromise._then(function(thisArg) {
- ret._setBoundTo(thisArg);
+ maybePromise._then(function() {
ret._resolveCallback(value);
}, ret._reject, ret._progress, ret, null);
} else {
- ret._setBoundTo(thisArg);
ret._resolveCallback(value);
}
return ret;
@@ -903,7 +848,8 @@ var captureStackTrace = (function stackDetection() {
catch(e) {
hasStackAfterThrow = ("stack" in e);
}
- if (!("stack" in err) && hasStackAfterThrow) {
+ if (!("stack" in err) && hasStackAfterThrow &&
+ typeof Error.stackTraceLimit === "number") {
stackFramePattern = v8stackFramePattern;
formatStack = v8stackFormatter;
return function captureStackTrace(o) {
@@ -1045,7 +991,7 @@ function safePredicate(predicate, e) {
CatchFilter.prototype.doFilter = function (e) {
var cb = this._callback;
var promise = this._promise;
- var boundTo = promise._boundTo;
+ var boundTo = promise._boundValue();
for (var i = 0, len = this._instances.length; i < len; ++i) {
var item = this._instances[i];
var itemIsErrorType = item === Error ||
@@ -1123,6 +1069,7 @@ return createContext;
},{}],10:[function(_dereq_,module,exports){
"use strict";
module.exports = function(Promise, CapturedTrace) {
+var getDomain = Promise._getDomain;
var async = _dereq_("./async.js");
var Warning = _dereq_("./errors.js").Warning;
var util = _dereq_("./util.js");
@@ -1137,7 +1084,13 @@ if (debugging) {
async.disableTrampolineIfNecessary();
}
+Promise.prototype._ignoreRejections = function() {
+ this._unsetRejectionIsUnhandled();
+ this._bitField = this._bitField | 16777216;
+};
+
Promise.prototype._ensurePossibleRejectionHandled = function () {
+ if ((this._bitField & 16777216) !== 0) return;
this._setRejectionIsUnhandled();
async.invokeLater(this._notifyUnhandledRejection, this, undefined);
};
@@ -1236,11 +1189,17 @@ Promise.prototype._warn = function(message) {
};
Promise.onPossiblyUnhandledRejection = function (fn) {
- possiblyUnhandledRejection = typeof fn === "function" ? fn : undefined;
+ var domain = getDomain();
+ possiblyUnhandledRejection =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
};
Promise.onUnhandledRejectionHandled = function (fn) {
- unhandledRejectionHandled = typeof fn === "function" ? fn : undefined;
+ var domain = getDomain();
+ unhandledRejectionHandled =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
};
Promise.longStackTraces = function () {
@@ -1273,7 +1232,6 @@ return function() {
"use strict";
var util = _dereq_("./util.js");
var isPrimitive = util.isPrimitive;
-var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
module.exports = function(Promise) {
var returner = function () {
@@ -1304,7 +1262,7 @@ Promise.prototype["return"] =
Promise.prototype.thenReturn = function (value) {
if (value === undefined) return this.then(returnUndefined);
- if (wrapsPrimitiveReceiver && isPrimitive(value)) {
+ if (isPrimitive(value)) {
return this._then(
wrapper(value, 2),
undefined,
@@ -1320,7 +1278,7 @@ Promise.prototype["throw"] =
Promise.prototype.thenThrow = function (reason) {
if (reason === undefined) return this.then(throwUndefined);
- if (wrapsPrimitiveReceiver && isPrimitive(reason)) {
+ if (isPrimitive(reason)) {
return this._then(
wrapper(reason, 1),
undefined,
@@ -1560,7 +1518,6 @@ Promise.filter = function (promises, fn, options) {
"use strict";
module.exports = function(Promise, NEXT_FILTER, tryConvertToPromise) {
var util = _dereq_("./util.js");
-var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
var isPrimitive = util.isPrimitive;
var thrower = util.thrower;
@@ -1582,7 +1539,7 @@ function throw$(r) {
}
function promisedFinally(ret, reasonOrValue, isFulfilled) {
var then;
- if (wrapsPrimitiveReceiver && isPrimitive(reasonOrValue)) {
+ if (isPrimitive(reasonOrValue)) {
then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue);
} else {
then = isFulfilled ? returnThis : throwThis;
@@ -1595,7 +1552,7 @@ function finallyHandler(reasonOrValue) {
var handler = this.handler;
var ret = promise._isBound()
- ? handler.call(promise._boundTo)
+ ? handler.call(promise._boundValue())
: handler();
if (ret !== undefined) {
@@ -1620,7 +1577,7 @@ function tapHandler(value) {
var handler = this.handler;
var ret = promise._isBound()
- ? handler.call(promise._boundTo, value)
+ ? handler.call(promise._boundValue(), value)
: handler(value);
if (ret !== undefined) {
@@ -1911,6 +1868,7 @@ module.exports = function(Promise,
apiRejection,
tryConvertToPromise,
INTERNAL) {
+var getDomain = Promise._getDomain;
var async = _dereq_("./async.js");
var util = _dereq_("./util.js");
var tryCatch = util.tryCatch;
@@ -1921,7 +1879,8 @@ var EMPTY_ARRAY = [];
function MappingPromiseArray(promises, fn, limit, _filter) {
this.constructor$(promises);
this._promise._captureStackTrace();
- this._callback = fn;
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
this._preservedValues = _filter === INTERNAL
? new Array(this.length())
: null;
@@ -1956,7 +1915,7 @@ MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
if (preservedValues !== null) preservedValues[index] = value;
var callback = this._callback;
- var receiver = this._promise._boundTo;
+ var receiver = this._promise._boundValue();
this._promise._pushContext();
var ret = tryCatch(callback).call(receiver, value, index, length);
this._promise._popContext();
@@ -2094,7 +2053,8 @@ var errorObj = util.errorObj;
function spreadAdapter(val, nodeback) {
var promise = this;
if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
- var ret = tryCatch(nodeback).apply(promise._boundTo, [null].concat(val));
+ var ret =
+ tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
if (ret === errorObj) {
async.throwLater(ret.e);
}
@@ -2102,7 +2062,7 @@ function spreadAdapter(val, nodeback) {
function successAdapter(val, nodeback) {
var promise = this;
- var receiver = promise._boundTo;
+ var receiver = promise._boundValue();
var ret = val === undefined
? tryCatch(nodeback).call(receiver, null)
: tryCatch(nodeback).call(receiver, null, val);
@@ -2118,13 +2078,13 @@ function errorAdapter(reason, nodeback) {
newReason.cause = reason;
reason = newReason;
}
- var ret = tryCatch(nodeback).call(promise._boundTo, reason);
+ var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
if (ret === errorObj) {
async.throwLater(ret.e);
}
}
-Promise.prototype.asCallback =
+Promise.prototype.asCallback =
Promise.prototype.nodeify = function (nodeback, options) {
if (typeof nodeback == "function") {
var adapter = successAdapter;
@@ -2233,7 +2193,23 @@ var reflect = function() {
var apiRejection = function(msg) {
return Promise.reject(new TypeError(msg));
};
+
var util = _dereq_("./util.js");
+
+var getDomain;
+if (util.isNode) {
+ getDomain = function() {
+ var ret = process.domain;
+ if (ret === undefined) ret = null;
+ return ret;
+ };
+} else {
+ getDomain = function() {
+ return null;
+ };
+}
+util.notEnumerableProp(Promise, "_getDomain", getDomain);
+
var async = _dereq_("./async.js");
var errors = _dereq_("./errors.js");
var TypeError = Promise.TypeError = errors.TypeError;
@@ -2432,8 +2408,12 @@ Promise.prototype._then = function (
if (!haveInternalData) ret._setIsMigrated();
}
- var callbackIndex =
- target._addCallbacks(didFulfill, didReject, didProgress, ret, receiver);
+ var callbackIndex = target._addCallbacks(didFulfill,
+ didReject,
+ didProgress,
+ ret,
+ receiver,
+ getDomain());
if (target._isResolved() && !target._isSettlePromisesQueued()) {
async.invoke(
@@ -2515,7 +2495,7 @@ Promise.prototype._receiverAt = function (index) {
: this[
index * 5 - 5 + 4];
if (ret === undefined && this._isBound()) {
- return this._boundTo;
+ return this._boundValue();
}
return ret;
};
@@ -2538,6 +2518,20 @@ Promise.prototype._rejectionHandlerAt = function (index) {
: this[index * 5 - 5 + 1];
};
+Promise.prototype._boundValue = function() {
+ var ret = this._boundTo;
+ if (ret !== undefined) {
+ if (ret instanceof Promise) {
+ if (ret.isFulfilled()) {
+ return ret.value();
+ } else {
+ return undefined;
+ }
+ }
+ }
+ return ret;
+};
+
Promise.prototype._migrateCallbacks = function (follower, index) {
var fulfill = follower._fulfillmentHandlerAt(index);
var reject = follower._rejectionHandlerAt(index);
@@ -2545,7 +2539,7 @@ Promise.prototype._migrateCallbacks = function (follower, index) {
var promise = follower._promiseAt(index);
var receiver = follower._receiverAt(index);
if (promise instanceof Promise) promise._setIsMigrated();
- this._addCallbacks(fulfill, reject, progress, promise, receiver);
+ this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
};
Promise.prototype._addCallbacks = function (
@@ -2553,7 +2547,8 @@ Promise.prototype._addCallbacks = function (
reject,
progress,
promise,
- receiver
+ receiver,
+ domain
) {
var index = this._length();
@@ -2565,20 +2560,34 @@ Promise.prototype._addCallbacks = function (
if (index === 0) {
this._promise0 = promise;
if (receiver !== undefined) this._receiver0 = receiver;
- if (typeof fulfill === "function" && !this._isCarryingStackTrace())
- this._fulfillmentHandler0 = fulfill;
- if (typeof reject === "function") this._rejectionHandler0 = reject;
- if (typeof progress === "function") this._progressHandler0 = progress;
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this._rejectionHandler0 =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this._progressHandler0 =
+ domain === null ? progress : domain.bind(progress);
+ }
} else {
var base = index * 5 - 5;
this[base + 3] = promise;
this[base + 4] = receiver;
- if (typeof fulfill === "function")
- this[base + 0] = fulfill;
- if (typeof reject === "function")
- this[base + 1] = reject;
- if (typeof progress === "function")
- this[base + 2] = progress;
+ if (typeof fulfill === "function") {
+ this[base + 0] =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this[base + 1] =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this[base + 2] =
+ domain === null ? progress : domain.bind(progress);
+ }
}
this._setLength(index + 1);
return index;
@@ -2673,7 +2682,7 @@ Promise.prototype._settlePromiseFromHandler = function (
promise._pushContext();
var x;
if (receiver === APPLY && !this._isRejected()) {
- x = tryCatch(handler).apply(this._boundTo, value);
+ x = tryCatch(handler).apply(this._boundValue(), value);
} else {
x = tryCatch(handler).call(receiver, value);
}
@@ -2743,8 +2752,6 @@ Promise.prototype._settlePromiseAt = function (index) {
this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
var value = this._settledValue;
var receiver = this._receiverAt(index);
-
-
this._clearCallbackDataAtIndex(index);
if (typeof handler === "function") {
@@ -2871,7 +2878,10 @@ Promise.prototype._settlePromises = function () {
}
};
-Promise._makeSelfResolutionError = makeSelfResolutionError;
+util.notEnumerableProp(Promise,
+ "_makeSelfResolutionError",
+ makeSelfResolutionError);
+
_dereq_("./progress.js")(Promise, PromiseArray);
_dereq_("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
_dereq_("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
@@ -3006,7 +3016,7 @@ PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
if (maybePromise instanceof Promise) {
maybePromise = maybePromise._target();
if (isResolved) {
- maybePromise._unsetRejectionIsUnhandled();
+ maybePromise._ignoreRejections();
} else if (maybePromise._isPending()) {
maybePromise._proxyPromiseArray(this, i);
} else if (maybePromise._isFulfilled()) {
@@ -3205,12 +3215,21 @@ var canEvaluate = util.canEvaluate;
var TypeError = _dereq_("./errors").TypeError;
var defaultSuffix = "Async";
var defaultPromisified = {__isPromisified__: true};
-var noCopyPropsPattern =
- /^(?:length|name|arguments|caller|callee|prototype|__isPromisified__)$/;
-var defaultFilter = function(name, func) {
+var noCopyProps = [
+ "arity", "length",
+ "name",
+ "arguments",
+ "caller",
+ "callee",
+ "prototype",
+ "__isPromisified__"
+];
+var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
+
+var defaultFilter = function(name) {
return util.isIdentifier(name) &&
name.charAt(0) !== "_" &&
- !util.isClass(func);
+ name !== "constructor";
};
function propsFilter(key) {
@@ -3354,6 +3373,7 @@ function(callback, receiver, originalName, fn) {
"nodebackForPromise",
"tryCatch",
"errorObj",
+ "notEnumerableProp",
"INTERNAL","'use strict'; \n\
var ret = function (Parameters) { \n\
'use strict'; \n\
@@ -3371,7 +3391,7 @@ function(callback, receiver, originalName, fn) {
} \n\
return promise; \n\
}; \n\
- ret.__isPromisified__ = true; \n\
+ notEnumerableProp(ret, '__isPromisified__', true); \n\
return ret; \n\
"
.replace("Parameters", parameterDeclaration(newParameterCount))
@@ -3385,6 +3405,7 @@ function(callback, receiver, originalName, fn) {
nodebackForPromise,
util.tryCatch,
util.errorObj,
+ util.notEnumerableProp,
INTERNAL
);
};
@@ -3411,7 +3432,7 @@ function makeNodePromisifiedClosure(callback, receiver, _, fn) {
}
return promise;
}
- promisified.__isPromisified__ = true;
+ util.notEnumerableProp(promisified, "__isPromisified__", true);
return promisified;
}
@@ -3714,6 +3735,7 @@ module.exports = function(Promise,
apiRejection,
tryConvertToPromise,
INTERNAL) {
+var getDomain = Promise._getDomain;
var async = _dereq_("./async.js");
var util = _dereq_("./util.js");
var tryCatch = util.tryCatch;
@@ -3742,7 +3764,8 @@ function ReductionPromiseArray(promises, fn, accum, _each) {
}
}
if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true;
- this._callback = fn;
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
this._accum = accum;
if (!rejected) async.invoke(init, this, undefined);
}
@@ -3796,7 +3819,7 @@ ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) {
if (!gotAccum) return;
var callback = this._callback;
- var receiver = this._promise._boundTo;
+ var receiver = this._promise._boundValue();
var ret;
for (var i = this._reducingIndex; i < length; ++i) {
@@ -3868,7 +3891,10 @@ if (util.isNode && typeof MutationObserver === "undefined") {
schedule = util.isRecentNode
? function(fn) { GlobalSetImmediate.call(global, fn); }
: function(fn) { ProcessNextTick.call(process, fn); };
-} else if (typeof MutationObserver !== "undefined") {
+} else if ((typeof MutationObserver !== "undefined") &&
+ !(typeof window !== "undefined" &&
+ window.navigator &&
+ window.navigator.standalone)) {
schedule = function(fn) {
var div = document.createElement("div");
var observer = new MutationObserver(fn);
@@ -4218,12 +4244,7 @@ function doThenable(x, then, context) {
function resolveFromThenable(value) {
if (!promise) return;
- if (x === value) {
- promise._rejectCallback(
- Promise._makeSelfResolutionError(), false, true);
- } else {
- promise._resolveCallback(value);
- }
+ promise._resolveCallback(value);
promise = null;
}
@@ -4533,7 +4554,9 @@ var errorObj = {e: {}};
var tryCatchTarget;
function tryCatcher() {
try {
- return tryCatchTarget.apply(this, arguments);
+ var target = tryCatchTarget;
+ tryCatchTarget = null;
+ return target.apply(this, arguments);
} catch (e) {
errorObj.e = e;
return errorObj;
@@ -4594,6 +4617,7 @@ function withAppended(target, appendee) {
function getDataPropertyOrDefault(obj, key, defaultValue) {
if (es5.isES5) {
var desc = Object.getOwnPropertyDescriptor(obj, key);
+
if (desc != null) {
return desc.get == null && desc.set == null
? desc.value
@@ -4616,23 +4640,32 @@ function notEnumerableProp(obj, name, value) {
return obj;
}
-
-var wrapsPrimitiveReceiver = (function() {
- return this !== "string";
-}).call("string");
-
function thrower(r) {
throw r;
}
var inheritedDataKeys = (function() {
+ var excludedPrototypes = [
+ Array.prototype,
+ Object.prototype,
+ Function.prototype
+ ];
+
+ var isExcludedProto = function(val) {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (excludedPrototypes[i] === val) {
+ return true;
+ }
+ }
+ return false;
+ };
+
if (es5.isES5) {
- var oProto = Object.prototype;
var getKeys = Object.getOwnPropertyNames;
return function(obj) {
var ret = [];
var visitedKeys = Object.create(null);
- while (obj != null && obj !== oProto) {
+ while (obj != null && !isExcludedProto(obj)) {
var keys;
try {
keys = getKeys(obj);
@@ -4653,11 +4686,23 @@ var inheritedDataKeys = (function() {
return ret;
};
} else {
+ var hasProp = {}.hasOwnProperty;
return function(obj) {
+ if (isExcludedProto(obj)) return [];
var ret = [];
+
/*jshint forin:false */
- for (var key in obj) {
- ret.push(key);
+ enumeration: for (var key in obj) {
+ if (hasProp.call(obj, key)) {
+ ret.push(key);
+ } else {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (hasProp.call(excludedPrototypes[i], key)) {
+ continue enumeration;
+ }
+ }
+ ret.push(key);
+ }
}
return ret;
};
@@ -4665,13 +4710,22 @@ var inheritedDataKeys = (function() {
})();
+var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
function isClass(fn) {
try {
if (typeof fn === "function") {
var keys = es5.names(fn.prototype);
- if (es5.isES5) return keys.length > 1;
- return keys.length > 0 &&
- !(keys.length === 1 && keys[0] === "constructor");
+
+ var hasMethods = es5.isES5 && keys.length > 1;
+ var hasMethodsOtherThanConstructor = keys.length > 0 &&
+ !(keys.length === 1 && keys[0] === "constructor");
+ var hasThisAssignmentAndStaticMethods =
+ thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
+
+ if (hasMethods || hasMethodsOtherThanConstructor ||
+ hasThisAssignmentAndStaticMethods) {
+ return true;
+ }
}
return false;
} catch (e) {
@@ -4751,7 +4805,9 @@ function copyDescriptors(from, to, filter) {
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (filter(key)) {
- es5.defineProperty(to, key, es5.getDescriptor(from, key));
+ try {
+ es5.defineProperty(to, key, es5.getDescriptor(from, key));
+ } catch (ignore) {}
}
}
}
@@ -4773,7 +4829,6 @@ var ret = {
inherits: inherits,
withAppended: withAppended,
maybeWrapAsError: maybeWrapAsError,
- wrapsPrimitiveReceiver: wrapsPrimitiveReceiver,
toFastProperties: toFastProperties,
filledRange: filledRange,
toString: safeToString,
@@ -4792,311 +4847,11 @@ ret.isRecentNode = ret.isNode && (function() {
var version = process.versions.node.split(".").map(Number);
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
})();
-try {throw new Error(); } catch (e) {ret.lastLineError = e;}
-module.exports = ret;
-
-},{"./es5.js":14}],39:[function(_dereq_,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
-}
-module.exports = EventEmitter;
-
-// Backwards-compat with node 0.10.x
-EventEmitter.EventEmitter = EventEmitter;
-
-EventEmitter.prototype._events = undefined;
-EventEmitter.prototype._maxListeners = undefined;
-
-// By default EventEmitters will print a warning if more than 10 listeners are
-// added to it. This is a useful default which helps finding memory leaks.
-EventEmitter.defaultMaxListeners = 10;
-
-// Obviously not all Emitters should be limited to 10. This function allows
-// that to be increased. Set to zero for unlimited.
-EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
-};
-
-EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
-
- if (!this._events)
- this._events = {};
-
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- }
- throw TypeError('Uncaught, unspecified "error" event.');
- }
- }
-
- handler = this._events[type];
-
- if (isUndefined(handler))
- return false;
-
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- len = arguments.length;
- args = new Array(len - 1);
- for (i = 1; i < len; i++)
- args[i - 1] = arguments[i];
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- len = arguments.length;
- args = new Array(len - 1);
- for (i = 1; i < len; i++)
- args[i - 1] = arguments[i];
-
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
-
- return true;
-};
-
-EventEmitter.prototype.addListener = function(type, listener) {
- var m;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events)
- this._events = {};
-
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
-
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
-
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- var m;
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
-
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
-
- return this;
-};
-
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-
-EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- var fired = false;
-
- function g() {
- this.removeListener(type, g);
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
-
- g.listener = listener;
- this.on(type, g);
-
- return this;
-};
-
-// emits a 'removeListener' event iff the listener was removed
-EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events || !this._events[type])
- return this;
-
- list = this._events[type];
- length = list.length;
- position = -1;
+if (ret.isNode) ret.toFastProperties(process);
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
-
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
-
- if (position < 0)
- return this;
-
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
-
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
-
- return this;
-};
-
-EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
-
- if (!this._events)
- return this;
-
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
-
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
-
- listeners = this._events[type];
-
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
-
- return this;
-};
-
-EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
-};
-
-EventEmitter.listenerCount = function(emitter, type) {
- var ret;
- if (!emitter._events || !emitter._events[type])
- ret = 0;
- else if (isFunction(emitter._events[type]))
- ret = 1;
- else
- ret = emitter._events[type].length;
- return ret;
-};
-
-function isFunction(arg) {
- return typeof arg === 'function';
-}
-
-function isNumber(arg) {
- return typeof arg === 'number';
-}
-
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
-
-function isUndefined(arg) {
- return arg === void 0;
-}
+try {throw new Error(); } catch (e) {ret.lastLineError = e;}
+module.exports = ret;
-},{}]},{},[4])(4)
+},{"./es5.js":14}]},{},[4])(4)
}); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; } \ No newline at end of file