Code coverage report for debug\bind.js

Statements: 100% (58 / 58)      Branches: 100% (12 / 12)      Functions: 100% (15 / 15)      Lines: 100% (54 / 54)      Ignored: none     

All files » debug\ » bind.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 91 92  8 8   18 18 8 30   8 18   30 8 333 333 90 27 63 12   51 51 51     51 51 51     270 270 270 270 270     8 36     8 45   45   45   45   45   45     8 123 6   6 6   6 6 6       8 1269     8 1217     8 17721     8 19009     8 28437          
(function () { "use strict";
module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
var ASSERT = require("./assert.js");
 
function returnThis() { return this.value; }
function throwThis() { throw this.reason; }
function awaitBindingThenResolve(value) {
    return this._then(returnThis, null, null, {value: value}, undefined);
}
function awaitBindingThenReject(reason) {
    return this._then(throwThis, throwThis, null, {reason: reason}, undefined);
}
function setBinding(binding) { this._setBoundTo(binding); }
Promise.prototype.bind = function (thisArg) {
    var maybePromise = tryConvertToPromise(thisArg);
    if (maybePromise instanceof Promise) {
        if (maybePromise.isFulfilled()) {
            thisArg = maybePromise.value();
        } else if (maybePromise.isRejected()) {
            return Promise.reject(maybePromise.reason());
        } else {
            var ret = this.then();
            var parent = ret;
            ret = ret._then(awaitBindingThenResolve,
                            awaitBindingThenReject,
                            null, maybePromise, undefined);
            maybePromise._then(setBinding, ret._reject, null, ret, null);
            if (!ret._cancellable()) ret._setPendingCancellationParent(parent);
            return ret;
        }
    }
    var ret = new Promise(INTERNAL);
    ret._propagateFrom(this, 1);
    ret._setBoundTo(thisArg);
    ret._follow(this._target());
    return ret;
};
 
Promise.bind = function (thisArg, value) {
    return Promise.resolve(value).bind(thisArg);
};
 
Promise.prototype._setPendingCancellationParent = function(parent) {
    ASSERT(this.isPending(),
    "this.isPending()");
    ASSERT(parent.isPending(),
    "parent.isPending()");
    ASSERT((! this._cancellable()),
    "!this._cancellable()");
    ASSERT((! parent._cancellable()),
    "!parent._cancellable()");
    ASSERT((parent instanceof Promise),
    "parent instanceof Promise");
    this._settledValue = parent;
};
 
Promise.prototype._pendingCancellationParent = function() {
    if (this.isPending() && this._settledValue !== undefined) {
        ASSERT((this._settledValue instanceof Promise),
    "this._settledValue instanceof Promise");
        var ret = this._settledValue;
        ASSERT((! ret._cancellable()),
    "!ret._cancellable()");
        ret.cancellable();
        this._settledValue = undefined;
        return ret;
    }
};
 
Promise.prototype._setIsMigratingBinding = function () {
    this._bitField = this._bitField | 8388608;
};
 
Promise.prototype._unsetIsMigratingBinding = function () {
    this._bitField = this._bitField & (~8388608);
};
 
Promise.prototype._isMigratingBinding = function () {
    return (this._bitField & 8388608) === 8388608;
};
 
Promise.prototype._setBoundTo = function (obj) {
    this._boundTo = obj;
};
 
Promise.prototype._isBound = function () {
    return this._boundTo !== undefined;
};
};
 
}());