await on synchronous functions

Bergi a.d.bergi at
Sun Jul 19 17:16:27 UTC 2015

Mark S. Miller wrote:

> We've talked about allowing await at the top level of modules, I think so
> that the await continuation could proceed after the synchronous part of the
> load. I am unclear on the details and cannot reconstruct a sensible story
> from memory.

I'd love to see that, using `await` in my main.js (or app.js or whatever 
it is called), so that I can write scripts using asynchronous functions 
without having to wrap everything in an IEAFE (immediately-executed 
asynchronous function expression).
Not sure whether such syntax might also be used with asynchronous module 
loaders, but at least at the top level of an app this would certainly be 

While `JSON.parse(await fs.readFile("options.json"))` could trivially be 
replaced with `fs.readFileSync`, such might not be the case for `await 


More information about the es-discuss mailing list