await on synchronous functions

Benjamin Gruenbaum benjamingr at
Sun Jul 26 12:07:49 UTC 2015

> Out of curiosity, can you give an example of the Not Good parts? ISTM the
await prefix is more of an explicit cast than an implicit conversation, and
other than the very small timing gap in how throws are handled I pointed
out a few days ago, I can't think of any situations where a throw would
make more sense than casting values to promises.

Sure, lots of such cases exist today with promises and are easy to reproduce

async function foo {
    let result = await bar; // instead of bar();
    let result2 = await callbackFn(); // await on function that was not
"promisified yet", that is, it takes a callback
    let result3 = await [p1, p2, p3]; // people might expect a Promise.all
on an array, but this doesn't actually wait for anything.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list