function delay(time) { return new Promise(resolve => setTimeout(resolve, time)); } async function test() { console.log('start timer'); await delay(1000); console.log('after 1 second'); } test();