Skip to main content
Home

@std/async@1.0.16
Built and signed on GitHub Actions

Utilities for asynchronous operations, like delays, debouncing, or pooling

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 weeks ago (1.0.16)
function delay
delay(
ms: number,
options?: DelayOptions,
): Promise<void>

Resolve a Promise after a given amount of milliseconds.

Examples

Basic usage

import { delay } from "@std/async/delay";

// ...
const delayedPromise = delay(100);
const result = await delayedPromise;
// ...

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

Duration in milliseconds for how long the delay should last.

optional
options: DelayOptions

Additional options.

Return Type

Promise<void>

Throws

DOMException

If the optional signal is aborted before the delay duration, and signal.reason is undefined.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/async

Import symbol

import { delay } from "@std/async";
or

Import directly with a jsr specifier

import { delay } from "jsr:@std/async";

Add Package

pnpm i jsr:@std/async
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/async

Import symbol

import { delay } from "@std/async";

Add Package

yarn add jsr:@std/async
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/async

Import symbol

import { delay } from "@std/async";

Add Package

vlt install jsr:@std/async

Import symbol

import { delay } from "@std/async";

Add Package

npx jsr add @std/async

Import symbol

import { delay } from "@std/async";

Add Package

bunx jsr add @std/async

Import symbol

import { delay } from "@std/async";