Code coverage report for debug\props.js

Statements: 100% (50 / 50)      Branches: 100% (8 / 8)      Functions: 100% (10 / 10)      Lines: 100% (50 / 50)      Ignored: none     

All files » debug\ » props.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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90  8   8 8 8 8   8 51 51 51 51 141 141 141   51   8   8 51     8 117   117   117 117 117 39 39 39 114   39       8 9     9           8 48     8 48     8 100 100   100 21 79 28     51     79 28   79     8 15     8 85          
(function () { "use strict";
module.exports = function(
    Promise, PromiseArray, tryConvertToPromise, apiRejection) {
var ASSERT = require("./assert.js");
var util = require("./util.js");
var isObject = util.isObject;
var es5 = require("./es5.js");
 
function PropertiesPromiseArray(obj) {
    var keys = es5.keys(obj);
    var len = keys.length;
    var values = new Array(len * 2);
    for (var i = 0; i < len; ++i) {
        var key = keys[i];
        values[i] = obj[key];
        values[i + len] = key;
    }
    this.constructor$(values);
}
util.inherits(PropertiesPromiseArray, PromiseArray);
 
PropertiesPromiseArray.prototype._init = function () {
    this._init$(undefined, -3) ;
};
 
PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
    ASSERT((! this._isResolved()),
    "!this._isResolved()");
    ASSERT((! (value instanceof Promise)),
    "!(value instanceof Promise)");
    this._values[index] = value;
    var totalResolved = ++this._totalResolved;
    if (totalResolved >= this._length) {
        var 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);
    }
};
 
PropertiesPromiseArray.prototype._promiseProgressed = function (value, index) {
    ASSERT((! this._isResolved()),
    "!this._isResolved()");
 
    this._promise._progress({
        key: this._values[index + this.length()],
        value: value
    });
};
 
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/OsFKC8\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, 4);
    }
    return ret;
}
 
Promise.prototype.props = function () {
    return props(this);
};
 
Promise.props = function (promises) {
    return props(promises);
};
};
 
}());