Skip to content

Instantly share code, notes, and snippets.

@kepta

kepta/block10.js Secret

Last active February 21, 2018 14:56
Show Gist options
  • Save kepta/b9f9b37dd4fe74dae32ad8968f719760 to your computer and use it in GitHub Desktop.
Save kepta/b9f9b37dd4fe74dae32ad8968f719760 to your computer and use it in GitHub Desktop.
function goodProm(maybePromise) {
return Promise.resolve(maybePromise);
}
goodProm(5).then(console.log); // 5
var fivePromise = fetchMeNumber(5); // this is a promise which resolves into number 5
goodProm(fivePromise).then(console.log); // 5
// Notice it unwraps all the layers of promises automagically!
goodProm(Promise.resolve(Promise.resolve(5))).then(console.log); // 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment