index.js
function invokeCallback(cb, invokeMethod, valueOrReason, promise, type) {
    var cbValue, cbError, errorThrown;

    try {
      cbValue = cb[invokeMethod](null, valueOrReason);
    } catch(err) { errorThrown = true, cbError = err; }

    // send return values in promise chain to downstream promise
    if (type === 'fulfill') {
      promise._values = this._values.concat([valueOrReason]);
    }

    if (!errorThrown && cbValue && typeof cbValue.then === 'function') {
      cbValue.then(
        function(value) { promise.fulfill(value); }
      , function(reason) { promise.reject(reason); }
      );
    }

    else {
      !errorThrown ? promise.fulfill(cbValue) : promise.reject(cbError);
    }
  }
function invokeCallback(cb, invokeMethod, valueOrReason, promise, type) {
    var cbValue, cbError, errorThrown;

    try {
      cbValue = cb[invokeMethod](null, valueOrReason);
    } catch(err) { errorThrown = true, cbError = err; }

    // send return values in promise chain to downstream promise
    if (type === 'fulfill') {
      promise._values = this._values.concat([valueOrReason]);
    }

    if (!errorThrown && cbValue && typeof cbValue.then === 'function') {
      cbValue.then(
        function(value) { promise.fulfill(value); }
      , function(reason) { promise.reject(reason); }
      );
    }

    else {
      !errorThrown ? promise.fulfill(cbValue) : promise.reject(cbError);
    }
  }
private instance methods ------------------------