Code coverage report for debug\race.js

Statements: 100% (26 / 26)      Branches: 100% (10 / 10)      Functions: 100% (6 / 6)      Lines: 100% (26 / 26)      Ignored: none     

All files » debug\ » race.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50  8   8   8 19 19       8 88   88 19 69 12     57 57 9   57 57 57 151   151 28     123   57     8 54     8 15            
(function () { "use strict";
module.exports = function(
    Promise, INTERNAL, tryConvertToPromise, apiRejection) {
var isArray = require("./util.js").isArray;
 
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 if (!isArray(promises)) {
        return apiRejection("expecting an array, a promise or a thenable\u000a\u000a    See http://goo.gl/s8MMhc\u000a");
    }
 
    var ret = new Promise(INTERNAL);
    if (parent !== undefined) {
        ret._propagateFrom(parent, 4 | 1);
    }
    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;
}
 
Promise.race = function (promises) {
    return race(promises, undefined);
};
 
Promise.prototype.race = function () {
    return race(this, undefined);
};
 
};
 
}());