1const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2
3(async () => {
4 console.log('1');
5 await delay(1000);
6 console.log('2');
7})();
1const { promisify } = require('util');
2
3const delay = promisify(setTimeout);
4
5// Usage:
6(async () => {
7 console.log('1');
8 await delay(1000);
9 console.log('2');
10})();