Code coverage report for debug\method.js

Statements: 100% (30 / 30)      Branches: 100% (8 / 8)      Functions: 100% (5 / 5)      Lines: 100% (30 / 30)      Ignored: none     

All files » debug\ » method.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 8   8 58 3   55 55 55 55 55 55 55 55       8 34 3   31 31 31 31     31 31 31     8 86   86 20   66            
(function () { "use strict";
module.exports =
function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
var util = require("./util.js");
var ASSERT = require("./assert.js");
var tryCatch = util.tryCatch;
 
Promise.method = function (fn) {
    if (typeof fn !== "function") {
        throw new Promise.TypeError("fn must be a function\u000a\u000a    See http://goo.gl/916lJJ\u000a");
    }
    return function () {
        var ret = new Promise(INTERNAL);
        ret._captureStackTrace();
        ret._pushContext();
        var value = tryCatch(fn).apply(this, arguments);
        ret._popContext();
        ret._resolveFromSyncValue(value);
        return ret;
    };
};
 
Promise.attempt = Promise["try"] = function (fn, args, ctx) {
    if (typeof fn !== "function") {
        return apiRejection("fn must be a function\u000a\u000a    See http://goo.gl/916lJJ\u000a");
    }
    var ret = new Promise(INTERNAL);
    ret._captureStackTrace();
    ret._pushContext();
    var value = util.isArray(args)
        ? tryCatch(fn).apply(ctx, args)
        : tryCatch(fn).call(ctx, args);
    ret._popContext();
    ret._resolveFromSyncValue(value);
    return ret;
};
 
Promise.prototype._resolveFromSyncValue = function (value) {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    if (value === util.errorObj) {
        this._rejectCallback(value.e, false, true);
    } else {
        this._resolveCallback(value);
    }
};
};
 
}());