function delay
delay(ms: number,options?: DelayOptions): Promise<void>Resolve a Promise after a given amount of milliseconds.
If the optional signal is aborted before the delay duration, the returned
promise rejects with the signal's reason. If no reason is provided to
abort(), the browser's default DOMException with name "AbortError" is used.
Examples
Basic usage
Basic usage
import { delay } from "@std/async/delay"; // ... const delayedPromise = delay(100); const result = await delayedPromise; // ...
Disable persistence
Disable persistence
Setting persistent to false will allow the process to continue to run as
long as the timer exists.
import { delay } from "@std/async/delay"; // ... await delay(100, { persistent: false }); // ...
Parameters
ms: numberDuration in milliseconds for how long the delay should last.
optional
options: DelayOptionsAdditional options.
Return Type
Promise<void>