3 var Promise = require('./core.js');
5 module.exports = Promise;
6 Promise.enableSynchronous = function () {
7 Promise.prototype.isPending = function() {
8 return this.getState() == 0;
11 Promise.prototype.isFulfilled = function() {
12 return this.getState() == 1;
15 Promise.prototype.isRejected = function() {
16 return this.getState() == 2;
19 Promise.prototype.getValue = function () {
21 return this._55.getValue();
24 if (!this.isFulfilled()) {
25 throw new Error('Cannot get a value of an unfulfilled promise.');
31 Promise.prototype.getReason = function () {
33 return this._55.getReason();
36 if (!this.isRejected()) {
37 throw new Error('Cannot get a rejection reason of a non-rejected promise.');
43 Promise.prototype.getState = function () {
45 return this._55.getState();
47 if (this._65 === -1 || this._65 === -2) {
55 Promise.disableSynchronous = function() {
56 Promise.prototype.isPending = undefined;
57 Promise.prototype.isFulfilled = undefined;
58 Promise.prototype.isRejected = undefined;
59 Promise.prototype.getValue = undefined;
60 Promise.prototype.getReason = undefined;
61 Promise.prototype.getState = undefined;