mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
more work
This commit is contained in:
54
node_modules/bluebird/js/main/direct_resolve.js
generated
vendored
Normal file
54
node_modules/bluebird/js/main/direct_resolve.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var util = require("./util.js");
|
||||
var isPrimitive = util.isPrimitive;
|
||||
var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver;
|
||||
|
||||
module.exports = function(Promise) {
|
||||
var returner = function () {
|
||||
return this;
|
||||
};
|
||||
var thrower = function () {
|
||||
throw this;
|
||||
};
|
||||
|
||||
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 (wrapsPrimitiveReceiver && isPrimitive(value)) {
|
||||
return this._then(
|
||||
wrapper(value, 2),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
return this._then(returner, undefined, undefined, value, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype["throw"] =
|
||||
Promise.prototype.thenThrow = function (reason) {
|
||||
if (wrapsPrimitiveReceiver && isPrimitive(reason)) {
|
||||
return this._then(
|
||||
wrapper(reason, 1),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
return this._then(thrower, undefined, undefined, reason, undefined);
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user