Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davefinster/084779154f4a7b4e747e2d0ed8d1781e to your computer and use it in GitHub Desktop.
Save davefinster/084779154f4a7b4e747e2d0ed8d1781e to your computer and use it in GitHub Desktop.
var suspendable = async (function () {
var promise1 = new Promise(.../* eventually produces the value 'p1' */);
var promise2 = new Promise(.../* eventually produces the value 'p2' */);
var thunk1 = function(callback) {.../* eventually produces the value 't1' */});
var thunk2 = function(callback) {.../* eventually produces the value 't2' */});
var thunk3 = ..., thunk4 = ...;
var r1 = await (promise1);
var r2 = await (thunk1);
var r3 = await (3.14);
var r4 = await ([promise2, 2, ['222', thunk2]]);
var r5 = await ({ t3: thunk3, t4: thunk4 });
return [r1, r2, r3, r4, r5];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment