Created
February 21, 2022 04:08
-
-
Save ashwinkumar2438/1608314ca85ec8ef4d93c1477827098a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PromiseCopy{ | |
static reject( reason ){ | |
// We return a new Promise and pass the reason to reject method if Promise.reject is called directly. | |
if( !( this instanceof PromiseCopy ) ) return new PromiseCopy( ( _ , rej ) => rej( reason ) ) ; | |
//return if promise is settled. | |
if( this.#state !== states.pending )return ; | |
this.#state = states.rejected ; | |
this.#result = reason ; | |
this.#dispatchCallbacks(); | |
} | |
#dispatchCallbacks(){ /* */ } ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment