Created
January 16, 2021 13:30
-
-
Save salami-art/03c45dd72440fed9703bce38e1475201 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 SyncPromise { | |
constructor( callback ) { | |
try{ | |
this.returnValue = callback(); | |
} | |
catch(err) { | |
throw err; | |
} | |
} | |
then(callback) { | |
callback(this.returnValue); | |
} | |
} | |
undefined | |
new SyncPromise((resolve, reject) => { return 'hello'}).then(value => console.log(value.toUpperCase())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment