Async snippets & functions

(, de)

Top level async function

(async () => {
    var text = await main();
    console.log(text);
})().catch(e => {
    // Deal with the fact the chain failed
});

Source

Delay execution

const delay = (ms) => new Promise((res) => setTimeout(res, ms))
await delay(5000);