Skip to main content
Module

x/timers/mod.ts>Timeout

All timing functions you need - for Deno and the browser
Go to Latest
class Timeout
extends Base<T>
import { Timeout } from "https://deno.land/x/timers@v0.1.0/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,
options?: TimeoutOptions<T>,
)

Type Parameters

optional
T extends any[] = any[]

Properties

readonly
options: TimeoutOptions<T>

Methods

abort(reason?: any)
run(): number