Code coverage report for debug\cancel.js

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

All files » debug\ » cancel.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  8 8 8 8 8   8 69 66 66 66   81   66   66 66     8 69 54 54 54     8 126 123 123 123     8 9 9 9 9 9     8 3     3 3 3          
(function () { "use strict";
module.exports = function(Promise, INTERNAL) {
var errors = require("./errors.js");
var async = require("./async.js");
var ASSERT = require("./assert.js");
var CancellationError = errors.CancellationError;
 
Promise.prototype._cancel = function (reason) {
    if (!this.isCancellable()) return this;
    var parent;
    var promiseToReject = this;
    while ((parent = promiseToReject._cancellationParent) !== undefined &&
        parent.isCancellable()) {
        promiseToReject = parent;
    }
    ASSERT(promiseToReject.isCancellable(),
    "promiseToReject.isCancellable()");
    this._unsetCancellable();
    promiseToReject._target()._rejectCallback(reason, false, true);
};
 
Promise.prototype.cancel = function (reason) {
    if (!this.isCancellable()) return this;
    if (reason === undefined) reason = new CancellationError();
    async.invokeLater(this._cancel, this, reason);
    return this;
};
 
Promise.prototype.cancellable = function () {
    if (this._cancellable()) return this;
    this._setCancellable();
    this._cancellationParent = this._pendingCancellationParent();
    return this;
};
 
Promise.prototype.uncancellable = function () {
    var ret = new Promise(INTERNAL);
    ret._propagateFrom(this, 4);
    ret._follow(this);
    ret._unsetCancellable();
    return ret;
};
 
Promise.prototype.fork = function (didFulfill, didReject, didProgress) {
    var ret = this._then(didFulfill, didReject, didProgress,
                         undefined, undefined);
 
    ret._setCancellable();
    ret._cancellationParent = undefined;
    return ret;
};
};
 
}());