Async/await are really handy, but I want the opposite of their behavior. Instead of other functions continuing on unless I manually ask them to await a promise, I want funct
Implicit await is bad, for reasons covered well in this blog. In short, consider why there's no need for locking in JavaScript. It's because we don't worry about being pre-empted willy-nilly.
Also, as mentioned by Daniel in comments, global await
is not allowed either, presumably for backwards compatibility.
You can work around this by wrapping your top-level code like this:
let wait = ms => new Promise(r => setTimeout(r, ms));
async function a() {
console.log("1");
await wait(5000);
console.log("2");
}
(async () => {
// Put your top level code here!
await a();
console.log("3");
})().catch(e => setTimeout(() => { throw e; }));
Not perfect, but gets the job done, without turning everything upside down.