delay es-toolkit
Delays code execution for a specified amount of time.
Usage
delay(ms, options?)
Use delay when you want to pause code execution for a specific amount of time. You can use it with async/await to make the next code execute after a certain time. If needed, you can also cancel the delay through an AbortSignal.
You can also cancel the delay using AbortSignal:
It's also useful for simulating asynchronous behavior in tests.
Parameters
The amount of time to delay in milliseconds.
Delay options.
signal(AbortSignal, optional): An AbortSignal to cancel the delay.
Returns
Returns a Promise that completes after the specified time.
Errors
Throws AbortError when the AbortSignal is activated.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.