Skip to content
Snippets Groups Projects
index.js 8.81 MiB
Newer Older
  • Learn to ignore specific revisions
  •                                  finallyHandler);
        } else {
             var catchInstances = new Array(len - 1),
                j = 0, i;
            for (i = 0; i < len - 1; ++i) {
                var item = arguments[i];
                if (util.isObject(item)) {
                    catchInstances[j++] = item;
                } else {
                    return Promise.reject(new TypeError(
                        "tapCatch statement predicate: "
                        + "expecting an object but got " + util.classString(item)
                    ));
                }
            }
            catchInstances.length = j;
            var handler = arguments[i];
            return this._passThrough(catchFilter(catchInstances, handler, this),
                                     1,
                                     undefined,
                                     finallyHandler);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    return PassThroughHandlerContext;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    /***/ }),
    
    /* 19 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    "use strict";
    
    
    module.exports = function(NEXT_FILTER) {
    var util = __webpack_require__(7);
    
    var getKeys = (__webpack_require__(8).keys);
    
    var tryCatch = util.tryCatch;
    var errorObj = util.errorObj;
    
    function catchFilter(instances, cb, promise) {
        return function(e) {
            var boundTo = promise._boundValue();
            predicateLoop: for (var i = 0; i < instances.length; ++i) {
                var item = instances[i];
    
                if (item === Error ||
                    (item != null && item.prototype instanceof Error)) {
                    if (e instanceof item) {
                        return tryCatch(cb).call(boundTo, e);
                    }
                } else if (typeof item === "function") {
                    var matchesPredicate = tryCatch(item).call(boundTo, e);
                    if (matchesPredicate === errorObj) {
                        return matchesPredicate;
                    } else if (matchesPredicate) {
                        return tryCatch(cb).call(boundTo, e);
                    }
                } else if (util.isObject(e)) {
                    var keys = getKeys(item);
                    for (var j = 0; j < keys.length; ++j) {
                        var key = keys[j];
                        if (item[key] != e[key]) {
                            continue predicateLoop;
                        }
                    }
                    return tryCatch(cb).call(boundTo, e);
                }
            }
            return NEXT_FILTER;
        };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    
    /* 20 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    "use strict";
    
    var util = __webpack_require__(7);
    var maybeWrapAsError = util.maybeWrapAsError;
    var errors = __webpack_require__(13);
    var OperationalError = errors.OperationalError;
    var es5 = __webpack_require__(8);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function isUntypedError(obj) {
        return obj instanceof Error &&
            es5.getPrototypeOf(obj) === Error.prototype;
    }
    
    var rErrorKey = /^(?:name|message|stack|cause)$/;
    function wrapAsOperationalError(obj) {
        var ret;
        if (isUntypedError(obj)) {
            ret = new OperationalError(obj);
            ret.name = obj.name;
            ret.message = obj.message;
            ret.stack = obj.stack;
            var keys = es5.keys(obj);
            for (var i = 0; i < keys.length; ++i) {
                var key = keys[i];
                if (!rErrorKey.test(key)) {
                    ret[key] = obj[key];
                }
            }
            return ret;
    
        util.markAsOriginatingFromRejection(obj);
        return obj;
    
    function nodebackForPromise(promise, multiArgs) {
        return function(err, value) {
            if (promise === null) return;
            if (err) {
                var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
                promise._attachExtraTrace(wrapped);
                promise._reject(wrapped);
            } else if (!multiArgs) {
                promise._fulfill(value);
            } else {
                var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
                promise._fulfill(args);
            }
            promise = null;
        };
    
    module.exports = nodebackForPromise;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 21 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports =
    function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
    var util = __webpack_require__(7);
    var tryCatch = util.tryCatch;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.method = function (fn) {
        if (typeof fn !== "function") {
            throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
        }
        return function () {
            var ret = new Promise(INTERNAL);
            ret._captureStackTrace();
            ret._pushContext();
            var value = tryCatch(fn).apply(this, arguments);
            var promiseCreated = ret._popContext();
            debug.checkForgottenReturns(
                value, promiseCreated, "Promise.method", ret);
            ret._resolveFromSyncValue(value);
            return ret;
        };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.attempt = Promise["try"] = function (fn) {
    
        if (typeof fn !== "function") {
            return apiRejection("expecting a function but got " + util.classString(fn));
        }
    
        var ret = new Promise(INTERNAL);
        ret._captureStackTrace();
        ret._pushContext();
        var value;
        if (arguments.length > 1) {
            debug.deprecated("calling Promise.try with more than 1 argument");
            var arg = arguments[1];
            var ctx = arguments[2];
            value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
                                      : tryCatch(fn).call(ctx, arg);
        } else {
            value = tryCatch(fn)();
    
        var promiseCreated = ret._popContext();
        debug.checkForgottenReturns(
            value, promiseCreated, "Promise.try", ret);
        ret._resolveFromSyncValue(value);
    
        return ret;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.prototype._resolveFromSyncValue = function (value) {
        if (value === util.errorObj) {
            this._rejectCallback(value.e, false);
        } else {
            this._resolveCallback(value, true);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    /* 22 */
    /***/ ((module) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    "use strict";
    
    module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
    var calledBind = false;
    var rejectThis = function(_, e) {
        this._reject(e);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var targetRejected = function(e, context) {
        context.promiseRejectionQueued = true;
        context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var bindingResolved = function(thisArg, context) {
        if (((this._bitField & 50397184) === 0)) {
            this._resolveCallback(context.target);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    };
    
    
    var bindingRejected = function(e, context) {
        if (!context.promiseRejectionQueued) this._reject(e);
    };
    
    Promise.prototype.bind = function (thisArg) {
        if (!calledBind) {
            calledBind = true;
            Promise.prototype._propagateFrom = debug.propagateFromFunction();
            Promise.prototype._boundValue = debug.boundValueFunction();
        }
        var maybePromise = tryConvertToPromise(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,
                promise: ret,
                target: target,
                bindingPromise: maybePromise
            };
            target._then(INTERNAL, targetRejected, undefined, ret, context);
            maybePromise._then(
                bindingResolved, bindingRejected, undefined, ret, context);
            ret._setOnCancel(maybePromise);
        } else {
            ret._resolveCallback(target);
        }
    
        return ret;
    };
    
    Promise.prototype._setBoundTo = function (obj) {
        if (obj !== undefined) {
            this._bitField = this._bitField | 2097152;
            this._boundTo = obj;
        } else {
            this._bitField = this._bitField & (~2097152);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._isBound = function () {
        return (this._bitField & 2097152) === 2097152;
    };
    
    Promise.bind = function (thisArg, value) {
        return Promise.resolve(value).bind(thisArg);
    };
    };
    
    
    /***/ }),
    /* 23 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    "use strict";
    
    module.exports = function(Promise, PromiseArray, apiRejection, debug) {
    var util = __webpack_require__(7);
    var tryCatch = util.tryCatch;
    var errorObj = util.errorObj;
    var async = Promise._async;
    
    Promise.prototype["break"] = Promise.prototype.cancel = function() {
        if (!debug.cancellation()) return this._warn("cancellation is disabled");
    
        var promise = this;
        var child = promise;
        while (promise._isCancellable()) {
            if (!promise._cancelBy(child)) {
                if (child._isFollowing()) {
                    child._followee().cancel();
    
                } else {
    
                    child._cancelBranched();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
            var parent = promise._cancellationParent;
            if (parent == null || !parent._isCancellable()) {
                if (promise._isFollowing()) {
                    promise._followee().cancel();
                } else {
                    promise._cancelBranched();
                }
                break;
    
            } else {
    
                if (promise._isFollowing()) promise._followee().cancel();
                promise._setWillBeCancelled();
                child = promise;
                promise = parent;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._branchHasCancelled = function() {
        this._branchesRemainingToCancel--;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._enoughBranchesHaveCancelled = function() {
        return this._branchesRemainingToCancel === undefined ||
               this._branchesRemainingToCancel <= 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._cancelBy = function(canceller) {
        if (canceller === this) {
            this._branchesRemainingToCancel = 0;
            this._invokeOnCancel();
            return true;
        } else {
            this._branchHasCancelled();
            if (this._enoughBranchesHaveCancelled()) {
                this._invokeOnCancel();
                return true;
            }
        }
        return false;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._cancelBranched = function() {
        if (this._enoughBranchesHaveCancelled()) {
            this._cancel();
        }
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._cancel = function() {
        if (!this._isCancellable()) return;
        this._setCancelled();
        async.invoke(this._cancelPromises, this, undefined);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._cancelPromises = function() {
        if (this._length() > 0) this._settlePromises();
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._unsetOnCancel = function() {
        this._onCancelField = undefined;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._isCancellable = function() {
        return this.isPending() && !this._isCancelled();
    
    Promise.prototype.isCancellable = function() {
        return this.isPending() && !this.isCancelled();
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
        if (util.isArray(onCancelCallback)) {
            for (var i = 0; i < onCancelCallback.length; ++i) {
                this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
            }
        } else if (onCancelCallback !== undefined) {
            if (typeof onCancelCallback === "function") {
                if (!internalOnly) {
                    var e = tryCatch(onCancelCallback).call(this._boundValue());
                    if (e === errorObj) {
                        this._attachExtraTrace(e.e);
                        async.throwLater(e.e);
                    }
                }
            } else {
                onCancelCallback._resultCancelled(this);
            }
        }
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._invokeOnCancel = function() {
        var onCancelCallback = this._onCancel();
        this._unsetOnCancel();
        async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._invokeInternalOnCancel = function() {
        if (this._isCancellable()) {
            this._doInvokeOnCancel(this._onCancel(), true);
            this._unsetOnCancel();
        }
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._resultCancelled = function() {
        this.cancel();
    
    /***/ }),
    /* 24 */
    /***/ ((module) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Promise) {
    function returner() {
        return this.value;
    }
    function thrower() {
        throw this.reason;
    }
    
    Promise.prototype["return"] =
    Promise.prototype.thenReturn = function (value) {
        if (value instanceof Promise) value.suppressUnhandledRejections();
        return this._then(
            returner, undefined, undefined, {value: value}, undefined);
    
    Promise.prototype["throw"] =
    Promise.prototype.thenThrow = function (reason) {
        return this._then(
            thrower, undefined, undefined, {reason: reason}, undefined);
    
    Promise.prototype.catchThrow = function (reason) {
        if (arguments.length <= 1) {
            return this._then(
                undefined, thrower, undefined, {reason: reason}, undefined);
        } else {
            var _reason = arguments[1];
            var handler = function() {throw _reason;};
            return this.caught(reason, handler);
    
    Promise.prototype.catchReturn = function (value) {
        if (arguments.length <= 1) {
            if (value instanceof Promise) value.suppressUnhandledRejections();
            return this._then(
                undefined, returner, undefined, {value: value}, undefined);
    
        } else {
    
            var _value = arguments[1];
            if (_value instanceof Promise) _value.suppressUnhandledRejections();
            var handler = function() {return _value;};
            return this.caught(value, handler);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    
    /***/ }),
    /* 25 */
    /***/ ((module) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Promise) {
    function PromiseInspection(promise) {
        if (promise !== undefined) {
            promise = promise._target();
            this._bitField = promise._bitField;
            this._settledValueField = promise._isFateSealed()
                ? promise._settledValue() : undefined;
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
        else {
            this._bitField = 0;
            this._settledValueField = undefined;
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    PromiseInspection.prototype._settledValue = function() {
        return this._settledValueField;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var value = PromiseInspection.prototype.value = function () {
        if (!this.isFulfilled()) {
            throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
    
        return this._settledValue();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var reason = PromiseInspection.prototype.error =
    PromiseInspection.prototype.reason = function () {
        if (!this.isRejected()) {
            throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
    
        return this._settledValue();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
        return (this._bitField & 33554432) !== 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var isRejected = PromiseInspection.prototype.isRejected = function () {
        return (this._bitField & 16777216) !== 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var isPending = PromiseInspection.prototype.isPending = function () {
        return (this._bitField & 50397184) === 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var isResolved = PromiseInspection.prototype.isResolved = function () {
        return (this._bitField & 50331648) !== 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    PromiseInspection.prototype.isCancelled = function() {
        return (this._bitField & 8454144) !== 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype.__isCancelled = function() {
        return (this._bitField & 65536) === 65536;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._isCancelled = function() {
        return this._target().__isCancelled();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.prototype.isCancelled = function() {
        return (this._target()._bitField & 8454144) !== 0;
    
    Promise.prototype.isPending = function() {
        return isPending.call(this._target());
    
    Promise.prototype.isRejected = function() {
        return isRejected.call(this._target());
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype.isFulfilled = function() {
        return isFulfilled.call(this._target());
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype.isResolved = function() {
        return isResolved.call(this._target());
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.prototype.value = function() {
        return value.call(this._target());
    
    Promise.prototype.reason = function() {
        var target = this._target();
        target._unsetRejectionIsUnhandled();
        return reason.call(target);
    
    Promise.prototype._value = function() {
        return this._settledValue();
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Promise.prototype._reason = function() {
        this._unsetRejectionIsUnhandled();
        return this._settledValue();
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.PromiseInspection = PromiseInspection;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    /***/ }),
    
    /* 26 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    "use strict";
    
    
    module.exports =
    function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async) {
    var util = __webpack_require__(7);
    var canEvaluate = util.canEvaluate;
    var tryCatch = util.tryCatch;
    var errorObj = util.errorObj;
    var reject;
    
    if (true) {
    if (canEvaluate) {
        var thenCallback = function(i) {
            return new Function("value", "holder", "                             \n\
                'use strict';                                                    \n\
                holder.pIndex = value;                                           \n\
                holder.checkFulfillment(this);                                   \n\
                ".replace(/Index/g, i));
        };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        var promiseSetter = function(i) {
            return new Function("promise", "holder", "                           \n\
                'use strict';                                                    \n\
                holder.pIndex = promise;                                         \n\
                ".replace(/Index/g, i));
        };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        var generateHolderClass = function(total) {
            var props = new Array(total);
            for (var i = 0; i < props.length; ++i) {
                props[i] = "this.p" + (i+1);
    
            var assignment = props.join(" = ") + " = null;";
            var cancellationCode= "var promise;\n" + props.map(function(prop) {
                return "                                                         \n\
                    promise = " + prop + ";                                      \n\
                    if (promise instanceof Promise) {                            \n\
                        promise.cancel();                                        \n\
                    }                                                            \n\
                ";
            }).join("\n");
            var passedArguments = props.join(", ");
            var name = "Holder$" + total;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
            var code = "return function(tryCatch, errorObj, Promise, async) {    \n\
                'use strict';                                                    \n\
                function [TheName](fn) {                                         \n\
                    [TheProperties]                                              \n\
                    this.fn = fn;                                                \n\
                    this.asyncNeeded = true;                                     \n\
                    this.now = 0;                                                \n\
                }                                                                \n\
                                                                                 \n\
                [TheName].prototype._callFunction = function(promise) {          \n\
                    promise._pushContext();                                      \n\
                    var ret = tryCatch(this.fn)([ThePassedArguments]);           \n\
                    promise._popContext();                                       \n\
                    if (ret === errorObj) {                                      \n\
                        promise._rejectCallback(ret.e, false);                   \n\
                    } else {                                                     \n\
                        promise._resolveCallback(ret);                           \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\
                [TheName].prototype._resultCancelled = function() {              \n\
                    [CancellationCode]                                           \n\
                };                                                               \n\
                                                                                 \n\
                return [TheName];                                                \n\
            }(tryCatch, errorObj, Promise, async);                               \n\
            ";
    
            code = code.replace(/\[TheName\]/g, name)
                .replace(/\[TheTotal\]/g, total)
                .replace(/\[ThePassedArguments\]/g, passedArguments)
                .replace(/\[TheProperties\]/g, assignment)
                .replace(/\[CancellationCode\]/g, cancellationCode);
    
            return new Function("tryCatch", "errorObj", "Promise", "async", code)
                               (tryCatch, errorObj, Promise, async);
        };
    
        var holderClasses = [];
        var thenCallbacks = [];
        var promiseSetters = [];
    
        for (var i = 0; i < 8; ++i) {
            holderClasses.push(generateHolderClass(i + 1));
            thenCallbacks.push(thenCallback(i + 1));
            promiseSetters.push(promiseSetter(i + 1));
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    
        reject = function (reason) {
            this._reject(reason);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.join = function () {
        var last = arguments.length - 1;
        var fn;
        if (last > 0 && typeof arguments[last] === "function") {
            fn = arguments[last];
            if (true) {
                if (last <= 8 && canEvaluate) {
                    var ret = new Promise(INTERNAL);
                    ret._captureStackTrace();
                    var HolderClass = holderClasses[last - 1];
                    var holder = new HolderClass(fn);
                    var callbacks = thenCallbacks;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
                    for (var i = 0; i < last; ++i) {
                        var maybePromise = tryConvertToPromise(arguments[i], ret);
                        if (maybePromise instanceof Promise) {
                            maybePromise = maybePromise._target();
                            var bitField = maybePromise._bitField;
                            ;
                            if (((bitField & 50397184) === 0)) {
                                maybePromise._then(callbacks[i], reject,
                                                   undefined, ret, holder);
                                promiseSetters[i](maybePromise, holder);
                                holder.asyncNeeded = false;
                            } else if (((bitField & 33554432) !== 0)) {
                                callbacks[i].call(ret,
                                                  maybePromise._value(), holder);
                            } else if (((bitField & 16777216) !== 0)) {
                                ret._reject(maybePromise._reason());
                            } else {
                                ret._cancel();
                            }
                        } else {
                            callbacks[i].call(ret, maybePromise, holder);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
                    if (!ret._isFateSealed()) {
                        if (holder.asyncNeeded) {
                            var context = Promise._getContext();
                            holder.fn = util.contextBind(context, holder.fn);
    
                        ret._setAsyncGuaranteed();
                        ret._setOnCancel(holder);
    
        var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len ; ++$_i) {args[$_i] = arguments[$_i ];};
        if (fn) args.pop();
        var ret = new PromiseArray(args).promise();
        return fn !== undefined ? ret.spread(fn) : ret;
    };
    
    /***/ }),
    /* 27 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    var cr = Object.create;
    if (cr) {
        var callerCache = cr(null);
        var getterCache = cr(null);
        callerCache[" size"] = getterCache[" size"] = 0;
    
    module.exports = function(Promise) {
    var util = __webpack_require__(7);
    var canEvaluate = util.canEvaluate;
    var isIdentifier = util.isIdentifier;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var getMethodCaller;
    var getGetter;
    if (true) {
    var makeMethodCaller = function (methodName) {
        return new Function("ensureMethod", "                                    \n\
            return function(obj) {                                               \n\
                'use strict'                                                     \n\
                var len = this.length;                                           \n\
                ensureMethod(obj, 'methodName');                                 \n\
                switch(len) {                                                    \n\
                    case 1: return obj.methodName(this[0]);                      \n\
                    case 2: return obj.methodName(this[0], this[1]);             \n\
                    case 3: return obj.methodName(this[0], this[1], this[2]);    \n\
                    case 0: return obj.methodName();                             \n\
                    default:                                                     \n\
                        return obj.methodName.apply(obj, this);                  \n\
                }                                                                \n\
            };                                                                   \n\
            ".replace(/methodName/g, methodName))(ensureMethod);
    };
    
    var makeGetter = function (propertyName) {
        return new Function("obj", "                                             \n\
            'use strict';                                                        \n\
            return obj.propertyName;                                             \n\
            ".replace("propertyName", propertyName));
    };
    
    var getCompiled = function(name, compiler, cache) {
        var ret = cache[name];
        if (typeof ret !== "function") {
            if (!isIdentifier(name)) {
                return null;
            }
            ret = compiler(name);
            cache[name] = ret;
            cache[" size"]++;
            if (cache[" size"] > 512) {
                var keys = Object.keys(cache);
                for (var i = 0; i < 256; ++i) delete cache[keys[i]];
                cache[" size"] = keys.length - 256;
            }
    
        return ret;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    getMethodCaller = function(name) {
        return getCompiled(name, makeMethodCaller, callerCache);
    };
    
    getGetter = function(name) {
        return getCompiled(name, makeGetter, getterCache);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function ensureMethod(obj, methodName) {
        var fn;
        if (obj != null) fn = obj[methodName];
        if (typeof fn !== "function") {
            var message = "Object " + util.classString(obj) + " has no method '" +
                util.toString(methodName) + "'";
            throw new Promise.TypeError(message);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function caller(obj) {
        var methodName = this.pop();
        var fn = ensureMethod(obj, methodName);
        return fn.apply(obj, this);
    
    Promise.prototype.call = function (methodName) {
        var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
        if (true) {
            if (canEvaluate) {
                var maybeCaller = getMethodCaller(methodName);
                if (maybeCaller !== null) {
                    return this._then(
                        maybeCaller, undefined, undefined, args, undefined);
                }
            }
        }
        args.push(methodName);
        return this._then(caller, undefined, undefined, args, undefined);
    };
    
    function namedGetter(obj) {
        return obj[this];
    
    function indexedGetter(obj) {
        var index = +this;
        if (index < 0) index = Math.max(0, index + obj.length);
        return obj[index];
    }
    Promise.prototype.get = function (propertyName) {
        var isIndex = (typeof propertyName === "number");
        var getter;
        if (!isIndex) {
            if (canEvaluate) {
                var maybeGetter = getGetter(propertyName);
                getter = maybeGetter !== null ? maybeGetter : namedGetter;
            } else {
                getter = namedGetter;
            }
    
        } else {
    
            getter = indexedGetter;
    
        return this._then(getter, undefined, undefined, propertyName, undefined);
    };
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 28 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    "use strict";
    
    module.exports = function(Promise,
                              apiRejection,
                              INTERNAL,
                              tryConvertToPromise,
                              Proxyable,
                              debug) {
    var errors = __webpack_require__(13);
    var TypeError = errors.TypeError;
    var util = __webpack_require__(7);
    var errorObj = util.errorObj;
    var tryCatch = util.tryCatch;
    var yieldHandlers = [];
    
    function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
        for (var i = 0; i < yieldHandlers.length; ++i) {
            traceParent._pushContext();
            var result = tryCatch(yieldHandlers[i])(value);
            traceParent._popContext();
            if (result === errorObj) {
                traceParent._pushContext();
                var ret = Promise.reject(errorObj.e);
                traceParent._popContext();
                return ret;
    
            var maybePromise = tryConvertToPromise(result, traceParent);
            if (maybePromise instanceof Promise) return maybePromise;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    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);
            promise._captureStackTrace();
    
        this._stack = stack;
        this._generatorFunction = generatorFunction;
        this._receiver = receiver;
        this._generator = undefined;
        this._yieldHandlers = typeof yieldHandler === "function"
            ? [yieldHandler].concat(yieldHandlers)
            : yieldHandlers;
        this._yieldedPromise = null;
        this._cancellationPhase = false;
    }
    util.inherits(PromiseSpawn, Proxyable);
    
    PromiseSpawn.prototype._isResolved = function() {
        return this._promise === null;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    PromiseSpawn.prototype._cleanup = function() {
        this._promise = this._generator = null;
        if (debug.cancellation() && this._finallyPromise !== null) {
            this._finallyPromise._fulfill();
            this._finallyPromise = null;
        }
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    PromiseSpawn.prototype._promiseCancelled = function() {
        if (this._isResolved()) return;
        var implementsReturn = typeof this._generator["return"] !== "undefined";
    
        var result;
        if (!implementsReturn) {
            var reason = new Promise.CancellationError(
                "generator .return() sentinel");
            Promise.coroutine.returnSentinel = reason;
            this._promise._attachExtraTrace(reason);
            this._promise._pushContext();
            result = tryCatch(this._generator["throw"]).call(this._generator,
                                                             reason);
            this._promise._popContext();
        } else {
            this._promise._pushContext();
            result = tryCatch(this._generator["return"]).call(this._generator,
                                                              undefined);
            this._promise._popContext();
        }
        this._cancellationPhase = true;
        this._yieldedPromise = null;
        this._continue(result);
    };
    
    PromiseSpawn.prototype._promiseFulfilled = function(value) {
        this._yieldedPromise = null;
        this._promise._pushContext();
        var result = tryCatch(this._generator.next).call(this._generator, value);
        this._promise._popContext();
        this._continue(result);
    };
    
    PromiseSpawn.prototype._promiseRejected = function(reason) {
        this._yieldedPromise = null;
        this._promise._attachExtraTrace(reason);
        this._promise._pushContext();
        var result = tryCatch(this._generator["throw"])
            .call(this._generator, reason);
        this._promise._popContext();
        this._continue(result);
    };
    
    PromiseSpawn.prototype._resultCancelled = function() {
        if (this._yieldedPromise instanceof Promise) {
            var promise = this._yieldedPromise;
            this._yieldedPromise = null;
            promise.cancel();
    
    PromiseSpawn.prototype.promise = function () {
        return this._promise;
    };