File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ require('./done.js');
55require ( './finally.js' ) ;
66require ( './es6-extensions.js' ) ;
77require ( './node-extensions.js' ) ;
8+ require ( './synchronous.js' ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var Promise = require ( './core.js' ) ;
4+
5+ module . exports = Promise ;
6+ Promise . enableSynchronous = function ( ) {
7+ Promise . prototype . isPending = function ( ) {
8+ return this . _state == 0 ;
9+ } ;
10+
11+ Promise . prototype . isFulfilled = function ( ) {
12+ return this . _state == 1 ;
13+ } ;
14+
15+ Promise . prototype . isRejected = function ( ) {
16+ return this . _state == 2 ;
17+ } ;
18+
19+ Promise . prototype . value = function ( ) {
20+ if ( ! this . isFulfilled ( ) ) {
21+ throw new Error ( 'Cannot get a value of an unfulfilled promise.' ) ;
22+ }
23+
24+ return this . _value ;
25+ } ;
26+
27+ Promise . prototype . reason = function ( ) {
28+ if ( ! this . isRejected ( ) ) {
29+ throw new Error ( 'Cannot get a rejection reason of a non-rejected promise.' ) ;
30+ }
31+
32+ return this . _value ;
33+ } ;
34+ } ;
You can’t perform that action at this time.
0 commit comments