@nodesuite/delay
TypeScript icon, indicating that this package has built-in type declarations

0.3.32 • Public • Published

nodesuite

@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!`)
}

Package Sidebar

Install

npm i @nodesuite/delay

Weekly Downloads

1

Version

0.3.32

License

ISC

Unpacked Size

117 kB

Total Files

21

Last publish

Collaborators

  • insidium