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