Code coverage report for debug\nodeify.js

Statements: 100% (40 / 40)      Branches: 100% (18 / 18)      Functions: 100% (5 / 5)      Lines: 100% (39 / 39)      Ignored: none     

All files » debug\ » nodeify.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  8 8 8 8 8 8   8 4 4 3 3 1       8 769 769 769   769     769 11     8 9 9 4 4   4 4 4 4     9   9 9 1       8 783 781 781 4   781               783          
(function () { "use strict";
module.exports = function(Promise) {
var util = require("./util.js");
var async = require("./async.js");
var ASSERT = require("./assert.js");
var tryCatch = util.tryCatch;
var errorObj = util.errorObj;
 
function spreadAdapter(val, nodeback) {
    var promise = this;
    if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
    var ret = tryCatch(nodeback).apply(promise._boundTo, [null].concat(val));
    if (ret === errorObj) {
        async.throwLater(ret.e);
    }
}
 
function successAdapter(val, nodeback) {
    var promise = this;
    var receiver = promise._boundTo;
    ASSERT(((typeof nodeback) == "function"),
    "typeof nodeback == \u0022function\u0022");
    var ret = val === undefined
        ? tryCatch(nodeback).call(receiver, null)
        : tryCatch(nodeback).call(receiver, null, val);
    if (ret === errorObj) {
        async.throwLater(ret.e);
    }
}
function errorAdapter(reason, nodeback) {
    var promise = this;
    if (!reason) {
        var target = promise._target();
        ASSERT(target._isCarryingStackTrace(),
    "target._isCarryingStackTrace()");
        var newReason = target._getCarriedStackTrace();
        newReason.cause = reason;
        reason = newReason;
        ASSERT((! (! reason)),
    "!!reason");
    }
    ASSERT(((typeof nodeback) == "function"),
    "typeof nodeback == \u0022function\u0022");
    var ret = tryCatch(nodeback).call(promise._boundTo, reason);
    if (ret === errorObj) {
        async.throwLater(ret.e);
    }
}
 
Promise.prototype.nodeify = function (nodeback, options) {
    if (typeof nodeback == "function") {
        var adapter = successAdapter;
        if (options !== undefined && Object(options).spread) {
            adapter = spreadAdapter;
        }
        this._then(
            adapter,
            errorAdapter,
            undefined,
            this,
            nodeback
        );
    }
    return this;
};
};
 
}());