Skip to content
Snippets Groups Projects
index.js 6.97 MiB
Newer Older
  • Learn to ignore specific revisions
  • Romain CREY's avatar
    Romain CREY committed
               typeof obj.name === "string");
    }
    
    function markAsOriginatingFromRejection(e) {
        try {
            notEnumerableProp(e, "isOperational", true);
        }
        catch(ignore) {}
    }
    
    function originatesFromRejection(e) {
        if (e == null) return false;
        return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
            e["isOperational"] === true);
    }
    
    function canAttachTrace(obj) {
        return isError(obj) && es5.propertyIsWritable(obj, "stack");
    }
    
    var ensureErrorObject = (function() {
        if (!("stack" in new Error())) {
            return function(value) {
                if (canAttachTrace(value)) return value;
                try {throw new Error(safeToString(value));}
                catch(err) {return err;}
            };
        } else {
            return function(value) {
                if (canAttachTrace(value)) return value;
                return new Error(safeToString(value));
            };
        }
    })();
    
    function classString(obj) {
        return {}.toString.call(obj);
    }
    
    function copyDescriptors(from, to, filter) {
        var keys = es5.names(from);
        for (var i = 0; i < keys.length; ++i) {
            var key = keys[i];
            if (filter(key)) {
                try {
                    es5.defineProperty(to, key, es5.getDescriptor(from, key));
                } catch (ignore) {}
            }
        }
    }
    
    var asArray = function(v) {
        if (es5.isArray(v)) {
            return v;
        }
        return null;
    };
    
    if (typeof Symbol !== "undefined" && Symbol.iterator) {
        var ArrayFrom = typeof Array.from === "function" ? function(v) {
            return Array.from(v);
        } : function(v) {
            var ret = [];
            var it = v[Symbol.iterator]();
            var itResult;
            while (!((itResult = it.next()).done)) {
                ret.push(itResult.value);
            }
            return ret;
        };
    
        asArray = function(v) {
            if (es5.isArray(v)) {
                return v;
            } else if (v != null && typeof v[Symbol.iterator] === "function") {
                return ArrayFrom(v);
            }
            return null;
        };
    }
    
    var isNode = typeof process !== "undefined" &&
            classString(process).toLowerCase() === "[object process]";
    
    var hasEnvVariables = typeof process !== "undefined" &&
        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]") {
    
    Romain CREY's avatar
    Romain CREY committed
                    return Promise;
                }
            } catch (e) {}
        }
    }
    
    
    function domainBind(self, cb) {
        return self.bind(cb);
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    var ret = {
        isClass: isClass,
        isIdentifier: isIdentifier,
        inheritedDataKeys: inheritedDataKeys,
        getDataPropertyOrDefault: getDataPropertyOrDefault,
        thrower: thrower,
        isArray: es5.isArray,
        asArray: asArray,
        notEnumerableProp: notEnumerableProp,
        isPrimitive: isPrimitive,
        isObject: isObject,
        isError: isError,
        canEvaluate: canEvaluate,
        errorObj: errorObj,
        tryCatch: tryCatch,
        inherits: inherits,
        withAppended: withAppended,
        maybeWrapAsError: maybeWrapAsError,
        toFastProperties: toFastProperties,
        filledRange: filledRange,
        toString: safeToString,
        canAttachTrace: canAttachTrace,
        ensureErrorObject: ensureErrorObject,
        originatesFromRejection: originatesFromRejection,
        markAsOriginatingFromRejection: markAsOriginatingFromRejection,
        classString: classString,
        copyDescriptors: copyDescriptors,
    
        hasDevTools: typeof chrome !== "undefined" && chrome &&
                     typeof chrome.loadTimes === "function",
    
    Romain CREY's avatar
    Romain CREY committed
        isNode: isNode,
        hasEnvVariables: hasEnvVariables,
        env: env,
        global: globalObject,
        getNativePromise: getNativePromise,
    
    Romain CREY's avatar
    Romain CREY committed
    };
    ret.isRecentNode = ret.isNode && (function() {
    
        var version = process.versions.node.split(".").map(Number);
    
    Romain CREY's avatar
    Romain CREY committed
        return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
    })();
    
    if (ret.isNode) ret.toFastProperties(process);
    
    try {throw new Error(); } catch (e) {ret.lastLineError = e;}
    module.exports = ret;
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports) {
    
    var isES5 = (function(){
        "use strict";
        return this === undefined;
    })();
    
    if (isES5) {
        module.exports = {
            freeze: Object.freeze,
            defineProperty: Object.defineProperty,
            getDescriptor: Object.getOwnPropertyDescriptor,
            keys: Object.keys,
            names: Object.getOwnPropertyNames,
            getPrototypeOf: Object.getPrototypeOf,
            isArray: Array.isArray,
            isES5: isES5,
            propertyIsWritable: function(obj, prop) {
                var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
                return !!(!descriptor || descriptor.writable || descriptor.set);
            }
        };
    } else {
        var has = {}.hasOwnProperty;
        var str = {}.toString;
        var proto = {}.constructor.prototype;
    
        var ObjectKeys = function (o) {
            var ret = [];
            for (var key in o) {
                if (has.call(o, key)) {
                    ret.push(key);
                }
            }
            return ret;
        };
    
        var ObjectGetDescriptor = function(o, key) {
            return {value: o[key]};
        };
    
        var ObjectDefineProperty = function (o, key, desc) {
            o[key] = desc.value;
            return o;
        };
    
        var ObjectFreeze = function (obj) {
            return obj;
        };
    
        var ObjectGetPrototypeOf = function (obj) {
            try {
                return Object(obj).constructor.prototype;
            }
            catch (e) {
                return proto;
            }
        };
    
        var ArrayIsArray = function (obj) {
            try {
                return str.call(obj) === "[object Array]";
            }
            catch(e) {
                return false;
            }
        };
    
        module.exports = {
            isArray: ArrayIsArray,
            keys: ObjectKeys,
            names: ObjectKeys,
            defineProperty: ObjectDefineProperty,
            getDescriptor: ObjectGetDescriptor,
            freeze: ObjectFreeze,
            getPrototypeOf: ObjectGetPrototypeOf,
            isES5: isES5,
            propertyIsWritable: function() {
                return true;
            }
        };
    }
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    var firstLineError;
    try {throw new Error(); } catch (e) {firstLineError = e;}
    
    var schedule = __webpack_require__(28);
    var Queue = __webpack_require__(29);
    var util = __webpack_require__(25);
    
    Romain CREY's avatar
    Romain CREY committed
    
    function Async() {
        this._customScheduler = false;
        this._isTickUsed = false;
        this._lateQueue = new Queue(16);
        this._normalQueue = new Queue(16);
        this._haveDrainedQueues = false;
    
        this._trampolineEnabled = true;
    
    Romain CREY's avatar
    Romain CREY committed
        var self = this;
        this.drainQueues = function () {
            self._drainQueues();
        };
        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() {
        this._trampolineEnabled = true;
    };
    
    Async.prototype.disableTrampolineIfNecessary = function() {
        if (util.hasDevTools) {
            this._trampolineEnabled = false;
        }
    };
    
    
    Romain CREY's avatar
    Romain CREY committed
    Async.prototype.haveItemsQueued = function () {
        return this._isTickUsed || this._haveDrainedQueues;
    };
    
    
    Async.prototype.fatalError = function(e, isNode) {
        if (isNode) {
            process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
                "\n");
            process.exit(2);
        } else {
            this.throwLater(e);
        }
    };
    
    Async.prototype.throwLater = function(fn, arg) {
        if (arguments.length === 1) {
            arg = fn;
            fn = function () { throw arg; };
        }
        if (typeof setTimeout !== "undefined") {
            setTimeout(function() {
                fn(arg);
            }, 0);
        } else try {
            this._schedule(function() {
                fn(arg);
            });
        } catch (e) {
            throw new Error("No async scheduler available\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
        }
    };
    
    function AsyncInvokeLater(fn, receiver, arg) {
        this._lateQueue.push(fn, receiver, arg);
        this._queueTick();
    }
    
    function AsyncInvoke(fn, receiver, arg) {
        this._normalQueue.push(fn, receiver, arg);
        this._queueTick();
    }
    
    function AsyncSettlePromises(promise) {
        this._normalQueue._pushOne(promise);
        this._queueTick();
    }
    
    
    if (!util.hasDevTools) {
        Async.prototype.invokeLater = AsyncInvokeLater;
        Async.prototype.invoke = AsyncInvoke;
        Async.prototype.settlePromises = AsyncSettlePromises;
    } else {
        Async.prototype.invokeLater = function (fn, receiver, arg) {
            if (this._trampolineEnabled) {
                AsyncInvokeLater.call(this, fn, receiver, arg);
            } else {
                this._schedule(function() {
                    setTimeout(function() {
                        fn.call(receiver, arg);
                    }, 100);
                });
            }
        };
    
        Async.prototype.invoke = function (fn, receiver, arg) {
            if (this._trampolineEnabled) {
                AsyncInvoke.call(this, fn, receiver, arg);
            } else {
                this._schedule(function() {
                    fn.call(receiver, arg);
                });
            }
        };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        Async.prototype.settlePromises = function(promise) {
            if (this._trampolineEnabled) {
                AsyncSettlePromises.call(this, promise);
            } else {
                this._schedule(function() {
                    promise._settlePromises();
                });
            }
        };
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    function _drainQueue(queue) {
        while (queue.length() > 0) {
            _drainQueueStep(queue);
        }
    }
    
    function _drainQueueStep(queue) {
        var fn = queue.shift();
        if (typeof fn !== "function") {
            fn._settlePromises();
        } else {
            var receiver = queue.shift();
            var arg = queue.shift();
            fn.call(receiver, arg);
        }
    }
    
    Async.prototype._drainQueues = function () {
        _drainQueue(this._normalQueue);
        this._reset();
        this._haveDrainedQueues = true;
        _drainQueue(this._lateQueue);
    };
    
    Async.prototype._queueTick = function () {
        if (!this._isTickUsed) {
            this._isTickUsed = true;
            this._schedule(this.drainQueues);
        }
    };
    
    Async.prototype._reset = function () {
        this._isTickUsed = false;
    };
    
    module.exports = Async;
    module.exports.firstLineError = firstLineError;
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    
    var util = __webpack_require__(25);
    
    Romain CREY's avatar
    Romain CREY committed
    var schedule;
    var noAsyncScheduler = function() {
        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") {
        var GlobalSetImmediate = global.setImmediate;
        var ProcessNextTick = process.nextTick;
        schedule = util.isRecentNode
                    ? function(fn) { GlobalSetImmediate.call(global, 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") &&
              !(typeof window !== "undefined" &&
                window.navigator &&
    
                (window.navigator.standalone || window.cordova))) {
    
    Romain CREY's avatar
    Romain CREY committed
        schedule = (function() {
            var div = document.createElement("div");
            var opts = {attributes: true};
            var toggleScheduled = false;
            var div2 = document.createElement("div");
            var o2 = new MutationObserver(function() {
                div.classList.toggle("foo");
                toggleScheduled = false;
            });
            o2.observe(div2, opts);
    
            var scheduleToggle = function() {
                if (toggleScheduled) return;
                toggleScheduled = true;
                div2.classList.toggle("foo");
            };
    
            return function schedule(fn) {
                var o = new MutationObserver(function() {
                    o.disconnect();
                    fn();
                });
                o.observe(div, opts);
                scheduleToggle();
            };
        })();
    } else if (typeof setImmediate !== "undefined") {
        schedule = function (fn) {
            setImmediate(fn);
        };
    } else if (typeof setTimeout !== "undefined") {
        schedule = function (fn) {
            setTimeout(fn, 0);
        };
    } else {
        schedule = noAsyncScheduler;
    }
    module.exports = schedule;
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    function arrayMove(src, srcIndex, dst, dstIndex, len) {
        for (var j = 0; j < len; ++j) {
            dst[j + dstIndex] = src[j + srcIndex];
            src[j + srcIndex] = void 0;
        }
    }
    
    function Queue(capacity) {
        this._capacity = capacity;
        this._length = 0;
        this._front = 0;
    }
    
    Queue.prototype._willBeOverCapacity = function (size) {
        return this._capacity < size;
    };
    
    Queue.prototype._pushOne = function (arg) {
        var length = this.length();
        this._checkCapacity(length + 1);
        var i = (this._front + length) & (this._capacity - 1);
        this[i] = arg;
        this._length = length + 1;
    };
    
    Queue.prototype.push = function (fn, receiver, arg) {
        var length = this.length() + 3;
        if (this._willBeOverCapacity(length)) {
            this._pushOne(fn);
            this._pushOne(receiver);
            this._pushOne(arg);
            return;
        }
        var j = this._front + length - 3;
        this._checkCapacity(length);
        var wrapMask = this._capacity - 1;
        this[(j + 0) & wrapMask] = fn;
        this[(j + 1) & wrapMask] = receiver;
        this[(j + 2) & wrapMask] = arg;
        this._length = length;
    };
    
    Queue.prototype.shift = function () {
        var front = this._front,
            ret = this[front];
    
        this[front] = undefined;
        this._front = (front + 1) & (this._capacity - 1);
        this._length--;
        return ret;
    };
    
    Queue.prototype.length = function () {
        return this._length;
    };
    
    Queue.prototype._checkCapacity = function (size) {
        if (this._capacity < size) {
            this._resizeTo(this._capacity << 1);
        }
    };
    
    Queue.prototype._resizeTo = function (capacity) {
        var oldCapacity = this._capacity;
        this._capacity = capacity;
        var front = this._front;
        var length = this._length;
        var moveItemsCount = (front + length) & (oldCapacity - 1);
        arrayMove(this, 0, this, oldCapacity, moveItemsCount);
    };
    
    module.exports = Queue;
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    
    var es5 = __webpack_require__(26);
    
    Romain CREY's avatar
    Romain CREY committed
    var Objectfreeze = es5.freeze;
    
    var util = __webpack_require__(25);
    
    Romain CREY's avatar
    Romain CREY committed
    var inherits = util.inherits;
    var notEnumerableProp = util.notEnumerableProp;
    
    function subError(nameProperty, defaultMessage) {
        function SubError(message) {
            if (!(this instanceof SubError)) return new SubError(message);
            notEnumerableProp(this, "message",
                typeof message === "string" ? message : defaultMessage);
            notEnumerableProp(this, "name", nameProperty);
            if (Error.captureStackTrace) {
                Error.captureStackTrace(this, this.constructor);
            } else {
                Error.call(this);
            }
        }
        inherits(SubError, Error);
        return SubError;
    }
    
    var _TypeError, _RangeError;
    var Warning = subError("Warning", "warning");
    var CancellationError = subError("CancellationError", "cancellation error");
    var TimeoutError = subError("TimeoutError", "timeout error");
    var AggregateError = subError("AggregateError", "aggregate error");
    try {
        _TypeError = TypeError;
        _RangeError = RangeError;
    } catch(e) {
        _TypeError = subError("TypeError", "type error");
        _RangeError = subError("RangeError", "range error");
    }
    
    var methods = ("join pop push shift unshift slice filter forEach some " +
        "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
    
    for (var i = 0; i < methods.length; ++i) {
        if (typeof Array.prototype[methods[i]] === "function") {
            AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
        }
    }
    
    es5.defineProperty(AggregateError.prototype, "length", {
        value: 0,
        configurable: false,
        writable: true,
        enumerable: true
    });
    AggregateError.prototype["isOperational"] = true;
    var level = 0;
    AggregateError.prototype.toString = function() {
        var indent = Array(level * 4 + 1).join(" ");
        var ret = "\n" + indent + "AggregateError of:" + "\n";
        level++;
        indent = Array(level * 4 + 1).join(" ");
        for (var i = 0; i < this.length; ++i) {
            var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
            var lines = str.split("\n");
            for (var j = 0; j < lines.length; ++j) {
                lines[j] = indent + lines[j];
            }
            str = lines.join("\n");
            ret += str + "\n";
        }
        level--;
        return ret;
    };
    
    function OperationalError(message) {
        if (!(this instanceof OperationalError))
            return new OperationalError(message);
        notEnumerableProp(this, "name", "OperationalError");
        notEnumerableProp(this, "message", message);
        this.cause = message;
        this["isOperational"] = true;
    
        if (message instanceof Error) {
            notEnumerableProp(this, "message", message.message);
            notEnumerableProp(this, "stack", message.stack);
        } else if (Error.captureStackTrace) {
            Error.captureStackTrace(this, this.constructor);
        }
    
    }
    inherits(OperationalError, Error);
    
    var errorTypes = Error["__BluebirdErrorTypes__"];
    if (!errorTypes) {
        errorTypes = Objectfreeze({
            CancellationError: CancellationError,
            TimeoutError: TimeoutError,
            OperationalError: OperationalError,
            RejectionError: OperationalError,
            AggregateError: AggregateError
        });
        es5.defineProperty(Error, "__BluebirdErrorTypes__", {
            value: errorTypes,
            writable: false,
            enumerable: false,
            configurable: false
        });
    }
    
    module.exports = {
        Error: Error,
        TypeError: _TypeError,
        RangeError: _RangeError,
        CancellationError: errorTypes.CancellationError,
        OperationalError: errorTypes.OperationalError,
        TimeoutError: errorTypes.TimeoutError,
        AggregateError: errorTypes.AggregateError,
        Warning: Warning
    };
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    module.exports = function(Promise, INTERNAL) {
    
    var util = __webpack_require__(25);
    
    Romain CREY's avatar
    Romain CREY committed
    var errorObj = util.errorObj;
    var isObject = util.isObject;
    
    function tryConvertToPromise(obj, context) {
        if (isObject(obj)) {
            if (obj instanceof Promise) return obj;
            var then = getThen(obj);
            if (then === errorObj) {
                if (context) context._pushContext();
                var ret = Promise.reject(then.e);
                if (context) context._popContext();
                return ret;
            } else if (typeof then === "function") {
                if (isAnyBluebirdPromise(obj)) {
                    var ret = new Promise(INTERNAL);
                    obj._then(
                        ret._fulfill,
                        ret._reject,
                        undefined,
                        ret,
                        null
                    );
                    return ret;
                }
                return doThenable(obj, then, context);
            }
        }
        return obj;
    }
    
    function doGetThen(obj) {
        return obj.then;
    }
    
    function getThen(obj) {
        try {
            return doGetThen(obj);
        } catch (e) {
            errorObj.e = e;
            return errorObj;
        }
    }
    
    var hasProp = {}.hasOwnProperty;
    function isAnyBluebirdPromise(obj) {
        try {
            return hasProp.call(obj, "_promise0");
        } catch (e) {
            return false;
        }
    }
    
    function doThenable(x, then, context) {
        var promise = new Promise(INTERNAL);
        var ret = promise;
        if (context) context._pushContext();
        promise._captureStackTrace();
        if (context) context._popContext();
        var synchronous = true;
        var result = util.tryCatch(then).call(x, resolve, reject);
        synchronous = false;
    
        if (promise && result === errorObj) {
            promise._rejectCallback(result.e, true, true);
            promise = null;
        }
    
        function resolve(value) {
            if (!promise) return;
            promise._resolveCallback(value);
            promise = null;
        }
    
        function reject(reason) {
            if (!promise) return;
            promise._rejectCallback(reason, synchronous, true);
            promise = null;
        }
        return ret;
    }
    
    return tryConvertToPromise;
    };
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    module.exports = function(Promise, INTERNAL, tryConvertToPromise,
        apiRejection, Proxyable) {
    
    var util = __webpack_require__(25);
    
    Romain CREY's avatar
    Romain CREY committed
    var isArray = util.isArray;
    
    function toResolutionValue(val) {
        switch(val) {
        case -2: return [];
        case -3: return {};
        case -6: return new Map();
        }
    }
    
    function PromiseArray(values) {
        var promise = this._promise = new Promise(INTERNAL);
        if (values instanceof Promise) {
            promise._propagateFrom(values, 3);
        }
        promise._setOnCancel(this);
        this._values = values;
        this._length = 0;
        this._totalResolved = 0;
        this._init(undefined, -2);
    }
    util.inherits(PromiseArray, Proxyable);
    
    PromiseArray.prototype.length = function () {
        return this._length;
    };
    
    PromiseArray.prototype.promise = function () {
        return this._promise;
    };
    
    PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
        var values = tryConvertToPromise(this._values, this._promise);
        if (values instanceof Promise) {
            values = values._target();
            var bitField = values._bitField;
            ;
            this._values = values;
    
            if (((bitField & 50397184) === 0)) {
                this._promise._setAsyncGuaranteed();
                return values._then(
                    init,
                    this._reject,
                    undefined,
                    this,
                    resolveValueIfEmpty
               );
            } else if (((bitField & 33554432) !== 0)) {
                values = values._value();
            } else if (((bitField & 16777216) !== 0)) {
                return this._reject(values._reason());
            } else {
                return this._cancel();
            }
        }
        values = util.asArray(values);
        if (values === null) {
            var err = apiRejection(
                "expecting an array or an iterable object but got " + util.classString(values)).reason();
            this._promise._rejectCallback(err, false);
            return;
        }
    
        if (values.length === 0) {
            if (resolveValueIfEmpty === -5) {
                this._resolveEmptyArray();
            }
            else {
                this._resolve(toResolutionValue(resolveValueIfEmpty));
            }
            return;
        }
        this._iterate(values);
    };
    
    PromiseArray.prototype._iterate = function(values) {
        var len = this.getActualLength(values.length);
        this._length = len;
        this._values = this.shouldCopyValues() ? new Array(len) : this._values;
        var result = this._promise;
        var isResolved = false;
        var bitField = null;
        for (var i = 0; i < len; ++i) {
            var maybePromise = tryConvertToPromise(values[i], result);
    
            if (maybePromise instanceof Promise) {
                maybePromise = maybePromise._target();
                bitField = maybePromise._bitField;
            } else {
                bitField = null;
            }
    
            if (isResolved) {
                if (bitField !== null) {
                    maybePromise.suppressUnhandledRejections();
                }
            } else if (bitField !== null) {
                if (((bitField & 50397184) === 0)) {
                    maybePromise._proxy(this, i);
                    this._values[i] = maybePromise;
                } else if (((bitField & 33554432) !== 0)) {
                    isResolved = this._promiseFulfilled(maybePromise._value(), i);
                } else if (((bitField & 16777216) !== 0)) {
                    isResolved = this._promiseRejected(maybePromise._reason(), i);
                } else {
                    isResolved = this._promiseCancelled(i);
                }
            } else {
                isResolved = this._promiseFulfilled(maybePromise, i);
            }
        }
        if (!isResolved) result._setAsyncGuaranteed();
    };
    
    PromiseArray.prototype._isResolved = function () {
        return this._values === null;
    };
    
    PromiseArray.prototype._resolve = function (value) {
        this._values = null;
        this._promise._fulfill(value);
    };
    
    PromiseArray.prototype._cancel = function() {
        if (this._isResolved() || !this._promise._isCancellable()) return;
        this._values = null;
        this._promise._cancel();
    };
    
    PromiseArray.prototype._reject = function (reason) {
        this._values = null;
        this._promise._rejectCallback(reason, false);
    };
    
    PromiseArray.prototype._promiseFulfilled = function (value, index) {
        this._values[index] = value;
        var totalResolved = ++this._totalResolved;
        if (totalResolved >= this._length) {
            this._resolve(this._values);
            return true;
        }
        return false;
    };
    
    PromiseArray.prototype._promiseCancelled = function() {
        this._cancel();
        return true;
    };
    
    PromiseArray.prototype._promiseRejected = function (reason) {
        this._totalResolved++;
        this._reject(reason);
        return true;
    };
    
    PromiseArray.prototype._resultCancelled = function() {
        if (this._isResolved()) return;
        var values = this._values;
        this._cancel();
        if (values instanceof Promise) {
            values.cancel();
        } else {
            for (var i = 0; i < values.length; ++i) {
                if (values[i] instanceof Promise) {
                    values[i].cancel();
                }
            }
        }
    };
    
    PromiseArray.prototype.shouldCopyValues = function () {
        return true;
    };
    
    PromiseArray.prototype.getActualLength = function (len) {
        return len;
    };
    
    return PromiseArray;
    };
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    module.exports = function(Promise) {
    var longStackTraces = false;
    var contextStack = [];
    
    Promise.prototype._promiseCreated = function() {};
    Promise.prototype._pushContext = function() {};
    Promise.prototype._popContext = function() {return null;};
    Promise._peekContext = Promise.prototype._peekContext = function() {};
    
    function Context() {
        this._trace = new Context.CapturedTrace(peekContext());
    }
    Context.prototype._pushContext = function () {
        if (this._trace !== undefined) {
            this._trace._promiseCreated = null;
            contextStack.push(this._trace);
        }
    };
    
    Context.prototype._popContext = function () {
        if (this._trace !== undefined) {
            var trace = contextStack.pop();
            var ret = trace._promiseCreated;
            trace._promiseCreated = null;
            return ret;
        }
        return null;