const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
(async () => {
console.log('1');
await delay(1000);
console.log('2');
})();
await Promise(resolve => setTimeout(resolve, ms));
const { promisify } = require('util');
const delay = promisify(setTimeout);
// Usage:
(async () => {
console.log('1');
await delay(1000);
console.log('2');
})();