Skip to content
Snippets Groups Projects
index.js 8.95 MiB
Newer Older
  • Learn to ignore specific revisions
  •     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;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    PromiseSpawn.prototype._run = function () {
        this._generator = this._generatorFunction.call(this._receiver);
        this._receiver =
            this._generatorFunction = undefined;
        this._promiseFulfilled(undefined);
    };
    
    PromiseSpawn.prototype._continue = function (result) {
        var promise = this._promise;
        if (result === errorObj) {
            this._cleanup();
            if (this._cancellationPhase) {
                return promise.cancel();
            } else {
                return promise._rejectCallback(result.e, false);
            }
    
        var value = result.value;
        if (result.done === true) {
            this._cleanup();
            if (this._cancellationPhase) {
                return promise.cancel();
            } else {
                return promise._resolveCallback(value);
            }
        } else {
            var maybePromise = tryConvertToPromise(value, this._promise);
            if (!(maybePromise instanceof Promise)) {
                maybePromise =
                    promiseFromYieldHandler(maybePromise,
                                            this._yieldHandlers,
                                            this._promise);
                if (maybePromise === null) {
                    this._promiseRejected(
                        new TypeError(
                            "A value %s was yielded that could not be treated as a promise\u000a\u000a    See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
                            "From coroutine:\u000a" +
                            this._stack.split("\n").slice(1, -7).join("\n")
                        )
                    );
                    return;
                }
            }
            maybePromise = maybePromise._target();
            var bitField = maybePromise._bitField;
            ;
            if (((bitField & 50397184) === 0)) {
                this._yieldedPromise = maybePromise;
                maybePromise._proxy(this, null);
            } else if (((bitField & 33554432) !== 0)) {
                Promise._async.invoke(
                    this._promiseFulfilled, this, maybePromise._value()
                );
            } else if (((bitField & 16777216) !== 0)) {
                Promise._async.invoke(
                    this._promiseRejected, this, maybePromise._reason()
                );
            } else {
                this._promiseCancelled();
            }
    
    };
    
    Promise.coroutine = function (generatorFunction, options) {
        if (typeof generatorFunction !== "function") {
            throw new TypeError("generatorFunction must be a function\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
    
        var yieldHandler = Object(options).yieldHandler;
        var PromiseSpawn$ = PromiseSpawn;
        var stack = new Error().stack;
        return function () {
            var generator = generatorFunction.apply(this, arguments);
            var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
                                          stack);
            var ret = spawn.promise();
            spawn._generator = generator;
            spawn._promiseFulfilled(undefined);
            return ret;
        };
    };
    
    Promise.coroutine.addYieldHandler = function(fn) {
        if (typeof fn !== "function") {
            throw new TypeError("expecting a function but got " + util.classString(fn));
        }
        yieldHandlers.push(fn);
    };
    
    Promise.spawn = function (generatorFunction) {
        debug.deprecated("Promise.spawn()", "Promise.coroutine()");
        if (typeof generatorFunction !== "function") {
            return apiRejection("generatorFunction must be a function\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
        }
        var spawn = new PromiseSpawn(generatorFunction, this);
        var ret = spawn.promise();
        spawn._run(Promise.spawn);
        return ret;
    };
    };
    
    /* 29 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    module.exports = function(Promise,
                              PromiseArray,
                              apiRejection,
                              tryConvertToPromise,
                              INTERNAL,
                              debug) {
    var util = __webpack_require__(7);
    var tryCatch = util.tryCatch;
    var errorObj = util.errorObj;
    var async = Promise._async;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function MappingPromiseArray(promises, fn, limit, _filter) {
        this.constructor$(promises);
        this._promise._captureStackTrace();
        var context = Promise._getContext();
        this._callback = util.contextBind(context, fn);
        this._preservedValues = _filter === INTERNAL
            ? new Array(this.length())
            : null;
        this._limit = limit;
        this._inFlight = 0;
        this._queue = [];
        async.invoke(this._asyncInit, this, undefined);
        if (util.isArray(promises)) {
            for (var i = 0; i < promises.length; ++i) {
                var maybePromise = promises[i];
                if (maybePromise instanceof Promise) {
                    maybePromise.suppressUnhandledRejections();
    
        }
    }
    util.inherits(MappingPromiseArray, PromiseArray);
    
    MappingPromiseArray.prototype._asyncInit = function() {
        this._init$(undefined, -2);
    };
    
    MappingPromiseArray.prototype._init = function () {};
    
    MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
        var values = this._values;
        var length = this.length();
        var preservedValues = this._preservedValues;
        var limit = this._limit;
    
        if (index < 0) {
            index = (index * -1) - 1;
            values[index] = value;
            if (limit >= 1) {
                this._inFlight--;
                this._drainQueue();
                if (this._isResolved()) return true;
    
        } else {
            if (limit >= 1 && this._inFlight >= limit) {
                values[index] = value;
                this._queue.push(index);
    
                return false;
            }
    
            if (preservedValues !== null) preservedValues[index] = value;
    
            var promise = this._promise;
            var callback = this._callback;
            var receiver = promise._boundValue();
            promise._pushContext();
            var ret = tryCatch(callback).call(receiver, value, index, length);
            var promiseCreated = promise._popContext();
            debug.checkForgottenReturns(
                ret,
                promiseCreated,
                preservedValues !== null ? "Promise.filter" : "Promise.map",
                promise
            );
            if (ret === errorObj) {
                this._reject(ret.e);
    
                return true;
            }
    
            var maybePromise = tryConvertToPromise(ret, this._promise);
            if (maybePromise instanceof Promise) {
                maybePromise = maybePromise._target();
                var bitField = maybePromise._bitField;
                ;
                if (((bitField & 50397184) === 0)) {
                    if (limit >= 1) this._inFlight++;
                    values[index] = maybePromise;
                    maybePromise._proxy(this, (index + 1) * -1);
                    return false;
                } else if (((bitField & 33554432) !== 0)) {
                    ret = maybePromise._value();
                } else if (((bitField & 16777216) !== 0)) {
                    this._reject(maybePromise._reason());
                    return true;
                } else {
                    this._cancel();
                    return true;
                }
            }
            values[index] = ret;
        }
        var totalResolved = ++this._totalResolved;
        if (totalResolved >= length) {
            if (preservedValues !== null) {
                this._filter(values, preservedValues);
            } else {
                this._resolve(values);
            }
            return true;
        }
        return false;
    };
    
    MappingPromiseArray.prototype._drainQueue = function () {
        var queue = this._queue;
        var limit = this._limit;
        var values = this._values;
        while (queue.length > 0 && this._inFlight < limit) {
            if (this._isResolved()) return;
            var index = queue.pop();
            this._promiseFulfilled(values[index], index);
        }
    };
    
    MappingPromiseArray.prototype._filter = function (booleans, values) {
        var len = values.length;
        var ret = new Array(len);
        var j = 0;
        for (var i = 0; i < len; ++i) {
            if (booleans[i]) ret[j++] = values[i];
        }
        ret.length = j;
        this._resolve(ret);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    MappingPromiseArray.prototype.preservedValues = function () {
        return this._preservedValues;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function map(promises, fn, options, _filter) {
        if (typeof fn !== "function") {
            return apiRejection("expecting a function but got " + util.classString(fn));
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        var limit = 0;
        if (options !== undefined) {
            if (typeof options === "object" && options !== null) {
                if (typeof options.concurrency !== "number") {
                    return Promise.reject(
                        new TypeError("'concurrency' must be a number but it is " +
                                        util.classString(options.concurrency)));
                }
                limit = options.concurrency;
            } else {
                return Promise.reject(new TypeError(
                                "options argument must be an object but it is " +
                                 util.classString(options)));
            }
        }
        limit = typeof limit === "number" &&
            isFinite(limit) && limit >= 1 ? limit : 0;
        return new MappingPromiseArray(promises, fn, limit, _filter).promise();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.prototype.map = function (fn, options) {
        return map(this, fn, options, null);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.map = function (promises, fn, options, _filter) {
        return map(promises, fn, options, _filter);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 30 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Promise) {
    var util = __webpack_require__(7);
    var async = Promise._async;
    var tryCatch = util.tryCatch;
    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._boundValue(), [null].concat(val));
        if (ret === errorObj) {
            async.throwLater(ret.e);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function successAdapter(val, nodeback) {
        var promise = this;
        var receiver = promise._boundValue();
        var ret = val === undefined
            ? tryCatch(nodeback).call(receiver, null)
            : tryCatch(nodeback).call(receiver, null, val);
        if (ret === errorObj) {
            async.throwLater(ret.e);
        }
    }
    function errorAdapter(reason, nodeback) {
        var promise = this;
        if (!reason) {
            var newReason = new Error(reason + "");
            newReason.cause = reason;
            reason = newReason;
        }
        var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
        if (ret === errorObj) {
            async.throwLater(ret.e);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    }
    
    
    Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
                                                                         options) {
        if (typeof nodeback == "function") {
            var adapter = successAdapter;
            if (options !== undefined && Object(options).spread) {
                adapter = spreadAdapter;
            }
            this._then(
                adapter,
                errorAdapter,
                undefined,
                this,
                nodeback
            );
    
    Romain CREY's avatar
    Romain CREY committed
    };
    };
    
    
    /***/ }),
    
    /* 31 */
    
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    "use strict";
    
    
    module.exports = function(Promise, INTERNAL) {
    var THIS = {};
    var util = __webpack_require__(7);
    var nodebackForPromise = __webpack_require__(20);
    var withAppended = util.withAppended;
    var maybeWrapAsError = util.maybeWrapAsError;
    var canEvaluate = util.canEvaluate;
    
    var TypeError = (__webpack_require__(13).TypeError);
    
    var defaultSuffix = "Async";
    var defaultPromisified = {__isPromisified__: true};
    var noCopyProps = [
        "arity",    "length",
        "name",
        "arguments",
        "caller",
        "callee",
        "prototype",
        "__isPromisified__"
    ];
    var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var defaultFilter = function(name) {
        return util.isIdentifier(name) &&
            name.charAt(0) !== "_" &&
            name !== "constructor";
    };
    
    function propsFilter(key) {
        return !noCopyPropsPattern.test(key);
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    function isPromisified(fn) {
        try {
            return fn.__isPromisified__ === true;
        }
        catch (e) {
            return false;
    
    function hasPromisified(obj, key, suffix) {
        var val = util.getDataPropertyOrDefault(obj, key + suffix,
                                                defaultPromisified);
        return val ? isPromisified(val) : false;
    }
    function checkValid(ret, suffix, suffixRegexp) {
        for (var i = 0; i < ret.length; i += 2) {
            var key = ret[i];
            if (suffixRegexp.test(key)) {
                var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
                for (var j = 0; j < ret.length; j += 2) {
                    if (ret[j] === keyWithoutAsyncSuffix) {
                        throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a    See http://goo.gl/MqrFmX\u000a"
                            .replace("%s", suffix));
                    }
                }
            }
        }
    
    function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
        var keys = util.inheritedDataKeys(obj);
        var ret = [];
        for (var i = 0; i < keys.length; ++i) {
            var key = keys[i];
            var value = obj[key];
            var passesDefaultFilter = filter === defaultFilter
                ? true : defaultFilter(key, value, obj);
            if (typeof value === "function" &&
                !isPromisified(value) &&
                !hasPromisified(obj, key, suffix) &&
                filter(key, value, obj, passesDefaultFilter)) {
                ret.push(key, value);
            }
        }
        checkValid(ret, suffix, suffixRegexp);
        return ret;
    }
    
    var escapeIdentRegex = function(str) {
        return str.replace(/([$])/, "\\$");
    
    var makeNodePromisifiedEval;
    if (true) {
    var switchCaseArgumentOrder = function(likelyArgumentCount) {
        var ret = [likelyArgumentCount];
        var min = Math.max(0, likelyArgumentCount - 1 - 3);
        for(var i = likelyArgumentCount - 1; i >= min; --i) {
            ret.push(i);
        }
        for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
            ret.push(i);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
        return ret;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var argumentSequence = function(argumentCount) {
        return util.filledRange(argumentCount, "_arg", "");
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var parameterDeclaration = function(parameterCount) {
        return util.filledRange(
            Math.max(parameterCount, 3), "_arg", "");
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    var parameterCount = function(fn) {
        if (typeof fn.length === "number") {
            return Math.max(Math.min(fn.length, 1023 + 1), 0);
        }
        return 0;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    makeNodePromisifiedEval =
    function(callback, receiver, originalName, fn, _, multiArgs) {
        var newParameterCount = Math.max(0, parameterCount(fn) - 1);
        var argumentOrder = switchCaseArgumentOrder(newParameterCount);
        var shouldProxyThis = typeof callback === "string" || receiver === THIS;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        function generateCallForArgumentCount(count) {
            var args = argumentSequence(count).join(", ");
            var comma = count > 0 ? ", " : "";
            var ret;
            if (shouldProxyThis) {
                ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
            } else {
                ret = receiver === undefined
                    ? "ret = callback({{args}}, nodeback); break;\n"
                    : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
            }
            return ret.replace("{{args}}", args).replace(", ", comma);
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        function generateArgumentSwitchCase() {
            var ret = "";
            for (var i = 0; i < argumentOrder.length; ++i) {
                ret += "case " + argumentOrder[i] +":" +
                    generateCallForArgumentCount(argumentOrder[i]);
            }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
            ret += "                                                             \n\
            default:                                                             \n\
                var args = new Array(len + 1);                                   \n\
                var i = 0;                                                       \n\
                for (var i = 0; i < len; ++i) {                                  \n\
                   args[i] = arguments[i];                                       \n\
                }                                                                \n\
                args[i] = nodeback;                                              \n\
                [CodeForCall]                                                    \n\
                break;                                                           \n\
            ".replace("[CodeForCall]", (shouldProxyThis
                                    ? "ret = callback.apply(this, args);\n"
                                    : "ret = callback.apply(receiver, args);\n"));
            return ret;
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        var getFunctionCode = typeof callback === "string"
                                    ? ("this != null ? this['"+callback+"'] : fn")
                                    : "fn";
        var body = "'use strict';                                                \n\
            var ret = function (Parameters) {                                    \n\
                'use strict';                                                    \n\
                var len = arguments.length;                                      \n\
                var promise = new Promise(INTERNAL);                             \n\
                promise._captureStackTrace();                                    \n\
                var nodeback = nodebackForPromise(promise, " + multiArgs + ");   \n\
                var ret;                                                         \n\
                var callback = tryCatch([GetFunctionCode]);                      \n\
                switch(len) {                                                    \n\
                    [CodeForSwitchCase]                                          \n\
                }                                                                \n\
                if (ret === errorObj) {                                          \n\
                    promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
                }                                                                \n\
                if (!promise._isFateSealed()) promise._setAsyncGuaranteed();     \n\
                return promise;                                                  \n\
            };                                                                   \n\
            notEnumerableProp(ret, '__isPromisified__', true);                   \n\
            return ret;                                                          \n\
        ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
            .replace("[GetFunctionCode]", getFunctionCode);
        body = body.replace("Parameters", parameterDeclaration(newParameterCount));
        return new Function("Promise",
                            "fn",
                            "receiver",
                            "withAppended",
                            "maybeWrapAsError",
                            "nodebackForPromise",
                            "tryCatch",
                            "errorObj",
                            "notEnumerableProp",
                            "INTERNAL",
                            body)(
                        Promise,
                        fn,
                        receiver,
                        withAppended,
                        maybeWrapAsError,
                        nodebackForPromise,
                        util.tryCatch,
                        util.errorObj,
                        util.notEnumerableProp,
                        INTERNAL);
    };
    }
    
    function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
        var defaultThis = (function() {return this;})();
        var method = callback;
        if (typeof method === "string") {
            callback = fn;
        }
        function promisified() {
            var _receiver = receiver;
            if (receiver === THIS) _receiver = this;
            var promise = new Promise(INTERNAL);
            promise._captureStackTrace();
            var cb = typeof method === "string" && this !== defaultThis
                ? this[method] : callback;
            var fn = nodebackForPromise(promise, multiArgs);
            try {
                cb.apply(_receiver, withAppended(arguments, fn));
            } catch(e) {
                promise._rejectCallback(maybeWrapAsError(e), true, true);
    
            if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
            return promise;
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
        util.notEnumerableProp(promisified, "__isPromisified__", true);
        return promisified;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var makeNodePromisified = canEvaluate
        ? makeNodePromisifiedEval
        : makeNodePromisifiedClosure;
    
    function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
        var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
        var methods =
            promisifiableMethods(obj, suffix, suffixRegexp, filter);
    
        for (var i = 0, len = methods.length; i < len; i+= 2) {
            var key = methods[i];
            var fn = methods[i+1];
            var promisifiedKey = key + suffix;
            if (promisifier === makeNodePromisified) {
                obj[promisifiedKey] =
                    makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
            } else {
                var promisified = promisifier(fn, function() {
                    return makeNodePromisified(key, THIS, key,
                                               fn, suffix, multiArgs);
                });
                util.notEnumerableProp(promisified, "__isPromisified__", true);
                obj[promisifiedKey] = promisified;
            }
    
        util.toFastProperties(obj);
        return obj;
    
    function promisify(callback, receiver, multiArgs) {
        return makeNodePromisified(callback, receiver, undefined,
                                    callback, null, multiArgs);
    }
    
    Promise.promisify = function (fn, options) {
        if (typeof fn !== "function") {
            throw new TypeError("expecting a function but got " + util.classString(fn));
    
        if (isPromisified(fn)) {
            return fn;
        }
        options = Object(options);
        var receiver = options.context === undefined ? THIS : options.context;
        var multiArgs = !!options.multiArgs;
        var ret = promisify(fn, receiver, multiArgs);
        util.copyDescriptors(fn, ret, propsFilter);
    
        return ret;
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.promisifyAll = function (target, options) {
        if (typeof target !== "function" && typeof target !== "object") {
            throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
    
        options = Object(options);
        var multiArgs = !!options.multiArgs;
        var suffix = options.suffix;
        if (typeof suffix !== "string") suffix = defaultSuffix;
        var filter = options.filter;
        if (typeof filter !== "function") filter = defaultFilter;
        var promisifier = options.promisifier;
        if (typeof promisifier !== "function") promisifier = makeNodePromisified;
    
        if (!util.isIdentifier(suffix)) {
            throw new RangeError("suffix must be a valid identifier\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
        }
    
        var keys = util.inheritedDataKeys(target);
        for (var i = 0; i < keys.length; ++i) {
            var value = target[keys[i]];
            if (keys[i] !== "constructor" &&
                util.isClass(value)) {
                promisifyAll(value.prototype, suffix, filter, promisifier,
                    multiArgs);
                promisifyAll(value, suffix, filter, promisifier, multiArgs);
            }
        }
    
        return promisifyAll(target, suffix, filter, promisifier, multiArgs);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    
    /* 32 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    "use strict";
    
    
    module.exports = function(
        Promise, PromiseArray, tryConvertToPromise, apiRejection) {
    var util = __webpack_require__(7);
    
    var isObject = util.isObject;
    
    var es5 = __webpack_require__(8);
    var Es6Map;
    if (typeof Map === "function") Es6Map = Map;
    
    var mapToEntries = (function() {
        var index = 0;
        var size = 0;
    
        function extractEntry(value, key) {
            this[index] = value;
            this[index + size] = key;
            index++;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        return function mapToEntries(map) {
            size = map.size;
            index = 0;
            var ret = new Array(map.size * 2);
            map.forEach(extractEntry, ret);
            return ret;
        };
    })();
    
    var entriesToMap = function(entries) {
        var ret = new Es6Map();
        var length = entries.length / 2 | 0;
        for (var i = 0; i < length; ++i) {
            var key = entries[length + i];
            var value = entries[i];
            ret.set(key, value);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function PropertiesPromiseArray(obj) {
        var isMap = false;
        var entries;
        if (Es6Map !== undefined && obj instanceof Es6Map) {
            entries = mapToEntries(obj);
            isMap = true;
        } else {
            var keys = es5.keys(obj);
            var len = keys.length;
            entries = new Array(len * 2);
            for (var i = 0; i < len; ++i) {
                var key = keys[i];
                entries[i] = obj[key];
                entries[i + len] = key;
            }
    
        this.constructor$(entries);
        this._isMap = isMap;
        this._init$(undefined, isMap ? -6 : -3);
    
    util.inherits(PropertiesPromiseArray, PromiseArray);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    PropertiesPromiseArray.prototype._init = function () {};
    
    PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
        this._values[index] = value;
        var totalResolved = ++this._totalResolved;
        if (totalResolved >= this._length) {
            var val;
            if (this._isMap) {
                val = entriesToMap(this._values);
            } else {
                val = {};
                var keyOffset = this.length();
                for (var i = 0, len = this.length(); i < len; ++i) {
                    val[this._values[i + keyOffset]] = this._values[i];
                }
            }
            this._resolve(val);
            return true;
    
    PropertiesPromiseArray.prototype.shouldCopyValues = function () {
        return false;
    };
    
    PropertiesPromiseArray.prototype.getActualLength = function (len) {
        return len >> 1;
    };
    
    function props(promises) {
        var ret;
        var castValue = tryConvertToPromise(promises);
    
        if (!isObject(castValue)) {
            return apiRejection("cannot await properties of a non-object\u000a\u000a    See http://goo.gl/MqrFmX\u000a");
        } else if (castValue instanceof Promise) {
            ret = castValue._then(
                Promise.props, undefined, undefined, undefined, undefined);
        } else {
            ret = new PropertiesPromiseArray(castValue).promise();
    
        if (castValue instanceof Promise) {
            ret._propagateFrom(castValue, 2);
    
    Promise.prototype.props = function () {
        return props(this);
    };
    
    Promise.props = function (promises) {
        return props(promises);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    /***/ }),
    
    /* 33 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    Romain CREY's avatar
    Romain CREY committed
    
    "use strict";
    
    
    module.exports = function(
        Promise, INTERNAL, tryConvertToPromise, apiRejection) {
    var util = __webpack_require__(7);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var raceLater = function (promise) {
        return promise.then(function(array) {
            return race(array, promise);
        });
    };
    
    function race(promises, parent) {
        var maybePromise = tryConvertToPromise(promises);
    
        if (maybePromise instanceof Promise) {
            return raceLater(maybePromise);
        } else {
            promises = util.asArray(promises);
            if (promises === null)
                return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        var ret = new Promise(INTERNAL);
        if (parent !== undefined) {
            ret._propagateFrom(parent, 3);
    
        var fulfill = ret._fulfill;
        var reject = ret._reject;
        for (var i = 0, len = promises.length; i < len; ++i) {
            var val = promises[i];
    
            if (val === undefined && !(i in promises)) {
                continue;
            }
    
            Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
        }
        return ret;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.race = function (promises) {
        return race(promises, undefined);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Promise.prototype.race = function () {
        return race(this, undefined);
    
    
    /***/ }),
    /* 34 */
    /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
    
    "use strict";
    
    module.exports = function(Promise,
                              PromiseArray,
                              apiRejection,
                              tryConvertToPromise,
                              INTERNAL,
                              debug) {
    var util = __webpack_require__(7);
    var tryCatch = util.tryCatch;
    
    function ReductionPromiseArray(promises, fn, initialValue, _each) {
        this.constructor$(promises);
        var context = Promise._getContext();
        this._fn = util.contextBind(context, fn);
        if (initialValue !== undefined) {
            initialValue = Promise.resolve(initialValue);
            initialValue._attachCancellationCallback(this);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
        this._initialValue = initialValue;
        this._currentCancellable = null;
        if(_each === INTERNAL) {
            this._eachValues = Array(this._length);
        } else if (_each === 0) {
            this._eachValues = null;
        } else {
            this._eachValues = undefined;
    
        this._promise._captureStackTrace();
        this._init$(undefined, -5);
    }
    util.inherits(ReductionPromiseArray, PromiseArray);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    ReductionPromiseArray.prototype._gotAccum = function(accum) {
        if (this._eachValues !== undefined &&
            this._eachValues !== null &&
            accum !== INTERNAL) {
            this._eachValues.push(accum);
    
    ReductionPromiseArray.prototype._eachComplete = function(value) {
        if (this._eachValues !== null) {
            this._eachValues.push(value);
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
        return this._eachValues;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    ReductionPromiseArray.prototype._init = function() {};
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    ReductionPromiseArray.prototype._resolveEmptyArray = function() {
        this._resolve(this._eachValues !== undefined ? this._eachValues
                                                     : this._initialValue);
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    ReductionPromiseArray.prototype.shouldCopyValues = function () {
        return false;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    ReductionPromiseArray.prototype._resolve = function(value) {
        this._promise._resolveCallback(value);
    
        this._values = null;
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    ReductionPromiseArray.prototype._resultCancelled = function(sender) {
        if (sender === this._initialValue) return this._cancel();
        if (this._isResolved()) return;
        this._resultCancelled$();
        if (this._currentCancellable instanceof Promise) {
            this._currentCancellable.cancel();
        }
        if (this._initialValue instanceof Promise) {
            this._initialValue.cancel();
    
    Romain CREY's avatar
    Romain CREY committed
    };
    
    
    ReductionPromiseArray.prototype._iterate = function (values) {
        this._values = values;
        var value;
        var i;
        var length = values.length;
        if (this._initialValue !== undefined) {
            value = this._initialValue;
            i = 0;
        } else {
            value = Promise.resolve(values[0]);
            i = 1;
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        this._currentCancellable = value;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        for (var j = i; j < length; ++j) {
            var maybePromise = values[j];
            if (maybePromise instanceof Promise) {
                maybePromise.suppressUnhandledRejections();
            }
        }
    
        if (!value.isRejected()) {
            for (; i < length; ++i) {
                var ctx = {
                    accum: null,
                    value: values[i],
                    index: i,
                    length: length,
                    array: this
                };
    
                value = value._then(gotAccum, undefined, undefined, ctx, undefined);
    
                if ((i & 127) === 0) {