You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node.js v15+ (v16 stable), Deno and Bun via node:timers/promises
Rationale
both packages wrap setTimeout in a promise, which node has built in. delay is ~7.8M weekly downloads and sleep-promise ~1.1M.
checked delay@7 and sleep-promise@9: await delay(ms, {value}) and setTimeout(ms, value) resolve with the same value, and both reject with AbortError when passed an aborted signal. sleep-promise also has a pass-through form (.then(sleep(ms))), which becomes .then((v) => setTimeout(ms, v)). delay's rangeDelay and clearDelay don't have a native equivalent.
makes sense, i'll do it as a micro-util with the node:timers/promises example and mention new Promise((resolve) => setTimeout(resolve, ms)) for browsers in the description
Activity
43081j commentedon Nov 24, 2026
i wonder if this should be a micro utility replacement so we can mention browser support too (
setTimeoutin a promise).thoughts? the example could use
node:timersbut the message could mention bothmaksimgm commentedon Nov 24, 2026
makes sense, i'll do it as a micro-util with the
node:timers/promisesexample and mentionnew Promise((resolve) => setTimeout(resolve, ms))for browsers in the description