Skip to content

Instantly share code, notes, and snippets.

@cyan33
Created November 14, 2017 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyan33/1bc5c1431e7d15d5406aeb168a12c200 to your computer and use it in GitHub Desktop.
Save cyan33/1bc5c1431e7d15d5406aeb168a12c200 to your computer and use it in GitHub Desktop.
async / await are just the syntax sugar of generators
async function addTwoResult(a, b) {
var first = await resolveAfter2Seconds(a);
var second = await resolveAfter2Seconds(b);
return first + second;
}
// is equivalent to
function *addTwoResult(a, b) {
var first = yield resolveAfter2Seconds(a);
var second = yield resolveAfter2Seconds(b);
return first + second;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment