@nodesuite/delay
v0.3.32
Published
Simple async delay function with commonly used aliases.
Downloads
11
Maintainers
Readme
@nodesuite/delay
Simple async timeout with optional randomization of range.
Important
If no randomization is required, do not use this package.
Instead, use the Node built-in setTimeout
from node:timers/promises
.
https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options
Usage
import { delay } from "@nodesuite/delay"
const example = async () => {
const start = Date.now()
await delay(1000, 2000)
const stop = Date.now()
console.log(`Randomized delay of ${stop - start}ms!`)
}