Comment

Comment by dfabulich

The new stable timers API in Node 16, combined with top-level await, means that you can now easily sleep in an ESM Node script, like this:

    import { setTimeout } from 'timers/promises';

    await setTimeout(1000);
    console.log("awake");
(But note that you'll have to activate ESM mode to write this script, e.g. by writing it in a `.mjs` file instead of a `.js` file or by adding a setting to package.json.) https://redfin.engineering/node-modules-at-war-why-commonjs-...
parent dfabulich 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton