EmperioAf,
понял, спасибо!
async function main() {
console.log('begin');
await wait(2000);
console.log('end');
}
function wait(ms) {
return new Promise(resolve => setTimeout(()=> {console.log("then");resolve()}, ms));
}
main().then(() => console.log('main is done'));