Skip to content

Instantly share code, notes, and snippets.

@idmontie
Created March 16, 2018 22:14
Show Gist options
  • Save idmontie/ff525d69daf2c0bfabe2ff57aa365385 to your computer and use it in GitHub Desktop.
Save idmontie/ff525d69daf2c0bfabe2ff57aa365385 to your computer and use it in GitHub Desktop.
Promises with thenable objects
function thenable(value) {
return {
then: function (onfulfill, onreject) {
onfulfill(value);
};
};
}
const promise = Promise.resolve(thenable('voila!'));
promise.then(function(result) {
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment