here's a real world example I use all the time:
const wait = (ms = 500) => new Promise(resolve => setTimeout(resolve, ms));
then: async function () {
await wait(1000);
}
Perhaps it's hard to grok but it sure is a handy one-liner.Of course in newer versions of node we can now do:
import {
setTimeout,
} from 'timers/promises';
await setTimeout(100);