Skip to content

Instantly share code, notes, and snippets.

@salami-art
Created January 16, 2021 13:30
Show Gist options
  • Save salami-art/03c45dd72440fed9703bce38e1475201 to your computer and use it in GitHub Desktop.
Save salami-art/03c45dd72440fed9703bce38e1475201 to your computer and use it in GitHub Desktop.
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