commit
This commit is contained in:
parent
a70448a434
commit
a15c733e45
55 changed files with 13236 additions and 1 deletions
94
node_modules/bluebird/js/main/synchronous_inspection.js
generated
vendored
Normal file
94
node_modules/bluebird/js/main/synchronous_inspection.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
function PromiseInspection(promise) {
|
||||
if (promise !== undefined) {
|
||||
promise = promise._target();
|
||||
this._bitField = promise._bitField;
|
||||
this._settledValue = promise._settledValue;
|
||||
}
|
||||
else {
|
||||
this._bitField = 0;
|
||||
this._settledValue = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
PromiseInspection.prototype.value = function () {
|
||||
if (!this.isFulfilled()) {
|
||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
|
||||
}
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.error =
|
||||
PromiseInspection.prototype.reason = function () {
|
||||
if (!this.isRejected()) {
|
||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
|
||||
}
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isFulfilled =
|
||||
Promise.prototype._isFulfilled = function () {
|
||||
return (this._bitField & 268435456) > 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isRejected =
|
||||
Promise.prototype._isRejected = function () {
|
||||
return (this._bitField & 134217728) > 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isPending =
|
||||
Promise.prototype._isPending = function () {
|
||||
return (this._bitField & 402653184) === 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isResolved =
|
||||
Promise.prototype._isResolved = function () {
|
||||
return (this._bitField & 402653184) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype.isPending = function() {
|
||||
return this._target()._isPending();
|
||||
};
|
||||
|
||||
Promise.prototype.isRejected = function() {
|
||||
return this._target()._isRejected();
|
||||
};
|
||||
|
||||
Promise.prototype.isFulfilled = function() {
|
||||
return this._target()._isFulfilled();
|
||||
};
|
||||
|
||||
Promise.prototype.isResolved = function() {
|
||||
return this._target()._isResolved();
|
||||
};
|
||||
|
||||
Promise.prototype._value = function() {
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype._reason = function() {
|
||||
this._unsetRejectionIsUnhandled();
|
||||
return this._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype.value = function() {
|
||||
var target = this._target();
|
||||
if (!target.isFulfilled()) {
|
||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
|
||||
}
|
||||
return target._settledValue;
|
||||
};
|
||||
|
||||
Promise.prototype.reason = function() {
|
||||
var target = this._target();
|
||||
if (!target.isRejected()) {
|
||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
|
||||
}
|
||||
target._unsetRejectionIsUnhandled();
|
||||
return target._settledValue;
|
||||
};
|
||||
|
||||
|
||||
Promise.PromiseInspection = PromiseInspection;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue