Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/delayed/src/sleep.ts>sleep

A simple module that provide an asynchronous approach to interval, delay and timeout
Go to Latest
function sleep
import { sleep } from "https://deno.land/x/delayed@2.0.2/src/sleep.ts";

Asynchronous sleep during the specified delay.

Examples

await sleep(500)
//wait 500ms
const ac = new AbortController()
await sleep(1_000_000, ac)
//ac called elsewhere, eg: callback
ac.abort()
//abort sleep before long sleep

Parameters

delay: ms
  • The amount of time to wait in milliseconds.
optional
unnamed 1: { signal?: AbortSignal; } = [UNSUPPORTED]

Returns

Promise<void>