2 module.exports = function(Promise) {
10 Promise.prototype["return"] =
11 Promise.prototype.thenReturn = function (value) {
12 if (value instanceof Promise) value.suppressUnhandledRejections();
14 returner, undefined, undefined, {value: value}, undefined);
17 Promise.prototype["throw"] =
18 Promise.prototype.thenThrow = function (reason) {
20 thrower, undefined, undefined, {reason: reason}, undefined);
23 Promise.prototype.catchThrow = function (reason) {
24 if (arguments.length <= 1) {
26 undefined, thrower, undefined, {reason: reason}, undefined);
28 var _reason = arguments[1];
29 var handler = function() {throw _reason;};
30 return this.caught(reason, handler);
34 Promise.prototype.catchReturn = function (value) {
35 if (arguments.length <= 1) {
36 if (value instanceof Promise) value.suppressUnhandledRejections();
38 undefined, returner, undefined, {value: value}, undefined);
40 var _value = arguments[1];
41 if (_value instanceof Promise) _value.suppressUnhandledRejections();
42 var handler = function() {return _value;};
43 return this.caught(value, handler);