Skip to content

Commit 72c8142

Browse files
committed
Merge pull request #4 from implausible/master
Fix promise synchronous polling
2 parents 61dcab0 + fadd3c3 commit 72c8142

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/synchronous.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Promise.enableSynchronous = function () {
1616
return this._state == 2;
1717
};
1818

19-
Promise.prototype.getValue = function () {
19+
Promise.prototype.value = function () {
2020
if (!this.isFulfilled()) {
2121
throw new Error('Cannot get a value of an unfulfilled promise.');
2222
}
2323

2424
return this._value;
2525
};
2626

27-
Promise.prototype.getReason = function () {
27+
Promise.prototype.reason = function () {
2828
if (!this.isRejected()) {
2929
throw new Error('Cannot get a rejection reason of a non-rejected promise.');
3030
}
@@ -37,8 +37,8 @@ Promise.disableSynchronous = function() {
3737
Promise.prototype.isPending = undefined;
3838
Promise.prototype.isFulfilled = undefined;
3939
Promise.prototype.isRejected = undefined;
40-
Promise.prototype.getValue = undefined;
41-
Promise.prototype.getReason = undefined;
40+
Promise.prototype.value = undefined;
41+
Promise.prototype.reason = undefined;
4242
};
4343

4444
Promise.enableSynchronous();

test/synchronous-inspection-tests.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('synchronous-inspection-tests', function () {
7070
setTimeout(function () {
7171
assert(fulfilledPromise.isFulfilled());
7272
assert(!fulfilledPromise.isRejected());
73-
assert(fulfilledPromise.getValue());
73+
assert(fulfilledPromise.value());
7474
assert(!fulfilledPromise.isPending());
7575
}, 30);
7676
});
@@ -102,7 +102,7 @@ describe('synchronous-inspection-tests', function () {
102102
setTimeout(function () {
103103
assert(!fulfilledPromise.isFulfilled());
104104
assert(fulfilledPromise.isRejected());
105-
assert(!fulfilledPromise.getReason());
105+
assert(!fulfilledPromise.reason());
106106
assert(!fulfilledPromise.isPending());
107107
}, 30);
108108
});
@@ -130,7 +130,7 @@ describe('synchronous-inspection-tests', function () {
130130
assert(!fulfilledPromise.isRejected());
131131

132132
try {
133-
fulfilledPromise.getValue();
133+
fulfilledPromise.value();
134134

135135
assert(false);
136136
}
@@ -142,7 +142,7 @@ describe('synchronous-inspection-tests', function () {
142142

143143
setTimeout(function () {
144144
try {
145-
fulfilledPromise.getValue();
145+
fulfilledPromise.value();
146146

147147
assert(false);
148148
}
@@ -175,7 +175,7 @@ describe('synchronous-inspection-tests', function () {
175175
assert(!fulfilledPromise.isRejected());
176176

177177
try {
178-
fulfilledPromise.getReason();
178+
fulfilledPromise.reason();
179179

180180
assert(false);
181181
}
@@ -187,7 +187,7 @@ describe('synchronous-inspection-tests', function () {
187187

188188
setTimeout(function () {
189189
try {
190-
fulfilledPromise.getReason();
190+
fulfilledPromise.reason();
191191

192192
assert(false);
193193
}
@@ -200,8 +200,8 @@ describe('synchronous-inspection-tests', function () {
200200
it('can disable synchronous inspection', function() {
201201
Promise.enableSynchronous();
202202
var testPromise = Promise.resolve('someValue');
203-
assert(testPromise.getValue() == 'someValue');
203+
assert(testPromise.value() == 'someValue');
204204
Promise.disableSynchronous();
205-
assert(testPromise.getValue == undefined);
205+
assert(testPromise.value == undefined);
206206
});
207207
});

0 commit comments

Comments
 (0)