react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / har-validator / node_modules / bluebird / js / main / synchronous_inspection.js
81160 views"use strict";1module.exports = function(Promise) {2function PromiseInspection(promise) {3if (promise !== undefined) {4promise = promise._target();5this._bitField = promise._bitField;6this._settledValue = promise._settledValue;7}8else {9this._bitField = 0;10this._settledValue = undefined;11}12}1314PromiseInspection.prototype.value = function () {15if (!this.isFulfilled()) {16throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");17}18return this._settledValue;19};2021PromiseInspection.prototype.error =22PromiseInspection.prototype.reason = function () {23if (!this.isRejected()) {24throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");25}26return this._settledValue;27};2829PromiseInspection.prototype.isFulfilled =30Promise.prototype._isFulfilled = function () {31return (this._bitField & 268435456) > 0;32};3334PromiseInspection.prototype.isRejected =35Promise.prototype._isRejected = function () {36return (this._bitField & 134217728) > 0;37};3839PromiseInspection.prototype.isPending =40Promise.prototype._isPending = function () {41return (this._bitField & 402653184) === 0;42};4344PromiseInspection.prototype.isResolved =45Promise.prototype._isResolved = function () {46return (this._bitField & 402653184) > 0;47};4849Promise.prototype.isPending = function() {50return this._target()._isPending();51};5253Promise.prototype.isRejected = function() {54return this._target()._isRejected();55};5657Promise.prototype.isFulfilled = function() {58return this._target()._isFulfilled();59};6061Promise.prototype.isResolved = function() {62return this._target()._isResolved();63};6465Promise.prototype._value = function() {66return this._settledValue;67};6869Promise.prototype._reason = function() {70this._unsetRejectionIsUnhandled();71return this._settledValue;72};7374Promise.prototype.value = function() {75var target = this._target();76if (!target.isFulfilled()) {77throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");78}79return target._settledValue;80};8182Promise.prototype.reason = function() {83var target = this._target();84if (!target.isRejected()) {85throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");86}87target._unsetRejectionIsUnhandled();88return target._settledValue;89};909192Promise.PromiseInspection = PromiseInspection;93};949596