react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / har-validator / node_modules / bluebird / js / main / direct_resolve.js
81160 views"use strict";1var util = require("./util.js");2var isPrimitive = util.isPrimitive;3var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;45module.exports = function(Promise) {6var returner = function () {7return this;8};9var thrower = function () {10throw this;11};12var returnUndefined = function() {};13var throwUndefined = function() {14throw undefined;15};1617var wrapper = function (value, action) {18if (action === 1) {19return function () {20throw value;21};22} else if (action === 2) {23return function () {24return value;25};26}27};282930Promise.prototype["return"] =31Promise.prototype.thenReturn = function (value) {32if (value === undefined) return this.then(returnUndefined);3334if (wrapsPrimitiveReceiver && isPrimitive(value)) {35return this._then(36wrapper(value, 2),37undefined,38undefined,39undefined,40undefined41);42}43return this._then(returner, undefined, undefined, value, undefined);44};4546Promise.prototype["throw"] =47Promise.prototype.thenThrow = function (reason) {48if (reason === undefined) return this.then(throwUndefined);4950if (wrapsPrimitiveReceiver && isPrimitive(reason)) {51return this._then(52wrapper(reason, 1),53undefined,54undefined,55undefined,56undefined57);58}59return this._then(thrower, undefined, undefined, reason, undefined);60};61};626364