Sha256: 4ba6cafacd4ea6e1a7101b6e59e4b6c4d2f76d5f651ab75ff13a65f7f1db3005

Contents?: true

Size: 1.43 KB

Versions: 25

Compression:

Stored size: 1.43 KB

Contents

"use strict";
var util = require("./util.js");
var isPrimitive = util.isPrimitive;

module.exports = function(Promise) {
var returner = function () {
    return this;
};
var thrower = function () {
    throw this;
};
var returnUndefined = function() {};
var throwUndefined = function() {
    throw undefined;
};

var wrapper = function (value, action) {
    if (action === 1) {
        return function () {
            throw value;
        };
    } else if (action === 2) {
        return function () {
            return value;
        };
    }
};


Promise.prototype["return"] =
Promise.prototype.thenReturn = function (value) {
    if (value === undefined) return this.then(returnUndefined);

    if (isPrimitive(value)) {
        return this._then(
            wrapper(value, 2),
            undefined,
            undefined,
            undefined,
            undefined
       );
    } else if (value instanceof Promise) {
        value._ignoreRejections();
    }
    return this._then(returner, undefined, undefined, value, undefined);
};

Promise.prototype["throw"] =
Promise.prototype.thenThrow = function (reason) {
    if (reason === undefined) return this.then(throwUndefined);

    if (isPrimitive(reason)) {
        return this._then(
            wrapper(reason, 1),
            undefined,
            undefined,
            undefined,
            undefined
       );
    }
    return this._then(thrower, undefined, undefined, reason, undefined);
};
};

Version data entries

25 entries across 19 versions & 6 rubygems

Version Path
ilog-0.4.1 node_modules/bluebird/js/main/direct_resolve.js
ilog-0.4.0 node_modules/bluebird/js/main/direct_resolve.js
ilog-0.3.3 node_modules/bluebird/js/main/direct_resolve.js
proxy_chain_rb-0.1.2 lib/proxy_chain_rb/node_js/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
proxy_chain_rb-0.1.0 lib/proxy_chain_rb/node_js/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.3.1 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.3.0 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.2.9 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.2.8 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.2.7 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
browsed-0.2.6 lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/bluebird/js/main/direct_resolve.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/fsevents/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/fsevents/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/bluebird/js/main/direct_resolve.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/fsevents/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/direct_resolve.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/bluebird/js/main/direct_resolve.js