This file contains 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 MyPromise { | |
constructor(executor) { | |
if (typeof executor !== 'function') { | |
throw new Error('Executor must be a function'); | |
} | |
// Internal state. `$state` is the state of the promise, and `$chained` is | |
// an array of the functions we need to call once this promise is settled. | |
this.$state = 'PENDING'; | |
this.$chained = []; |