2 var util = require("./util.js");
3 var isPrimitive = util.isPrimitive;
5 module.exports = function(Promise) {
6 var returner = function () {
9 var thrower = function () {
12 var returnUndefined = function() {};
13 var throwUndefined = function() {
17 var wrapper = function (value, action) {
22 } else if (action === 2) {
30 Promise.prototype["return"] =
31 Promise.prototype.thenReturn = function (value) {
32 if (value === undefined) return this.then(returnUndefined);
34 if (isPrimitive(value)) {
42 } else if (value instanceof Promise) {
43 value._ignoreRejections();
45 return this._then(returner, undefined, undefined, value, undefined);
48 Promise.prototype["throw"] =
49 Promise.prototype.thenThrow = function (reason) {
50 if (reason === undefined) return this.then(throwUndefined);
52 if (isPrimitive(reason)) {
61 return this._then(thrower, undefined, undefined, reason, undefined);