Skip to content

Instantly share code, notes, and snippets.

@MayaLekova
Created June 13, 2018 22:42
Show Gist options
  • Save MayaLekova/3b0eb851baf7e6d6d6e863e5e3562f1d to your computer and use it in GitHub Desktop.
Save MayaLekova/3b0eb851baf7e6d6d6e863e5e3562f1d to your computer and use it in GitHub Desktop.
Interleaving of await and promises
async function pr(v) { console.log("pr(" + v + ")"); }
async function f() { for (var i = 0; i < 10; i++) { await pr(i); } return 0; }
function ct(v) { console.log("counter" + v); if (v > 0) Promise.resolve(v - 1).then(ct); }
ct(10); f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment