Skip to main content
Module

x/timers/mod.ts>delay

All timing functions you need - for Deno and the browser
Go to Latest
function delay
import { delay } from "https://deno.land/x/timers@v0.1.0/mod.ts";

Resolves after the given number of milliseconds.

Parameters

ms: number

milliseconds to wait

const MSG = "Please type your name";
const info = document.querySelector("p.info");
const nameInput = document.querySelector("input.name");
const abort = new AbortController();
const { signal } = abort;

nameInput.addEventListener("input", () => abort.abort(), { once: true });

await delay(2000, {
signal
});

info.textContent = MSG;
optional
options: Omit<TimeoutOptions, "args"> = [UNSUPPORTED]

Returns

Promise<void>