Skip to main content
Module

x/timers/mod.ts>Timeout

All timing functions you need - long and async timeouts, intervals, promise timeouts and more
Go to Latest
class Timeout
extends Timer<T>
Re-export
import { Timeout } from "https://deno.land/x/timers@v0.2.1/mod.ts";

Examples

Example 1

const abort = new AbortController();
const { signal } = abort;
const timeout = new Timeout(
  () => {
    console.log("hello world");
  },
  100,
  { signal, }
);

timeout.run();

yourService.addEventListener("error", () => abort.abort(), { once: true })

Constructors

new
Timeout(
cb: Listener<T>,
delay?: number | string,
options?: TimeoutOptions<T>,
)

Type Parameters

optional
T extends any[] = any[]

Properties

protected
_ran: boolean
readonly
options: TimeoutOptions<T>
readonly
ran

Methods

run(): number