Skip to main content
Module

x/timers/mod.ts>Timer

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

Constructors

new
Timer(
cb: Listener<T>,
delay: number | string,
options: TimerOptions<T>,
)

Type Parameters

optional
T extends any[] = any[]

Properties

protected
_isAborted: boolean

A boolean value that indicates whether the timer has been aborted

protected
_persistent: boolean

Indicates whether the process should continue to run as long as the timer exists. This is true by default.

protected
_ran: boolean

Indicates whether the timer ran already

protected
_resolveAborted: (value: AbortException) => void
protected
_running: boolean

Indicates whether the timer is currently running

protected
_timeLeft: number
protected
optional
_timer: number

The timer Id

abort: (reason?: any) => unknown

aborts the timer

readonly
aborted: Promise<AbortException>

A Promise, that resolves when the timer gets aborted

readonly
delay: number
readonly
id: number
readonly
isAborted

A boolean value that indicates whether the timer has been aborted

readonly
options: TimerOptions<T>
readonly
persistent

Indicates whether the process should continue to run as long as the timer exists. This is true by default.

readonly
running

Indicates whether the timer is currently running

deprecated
readonly
timer

The timer Id

Methods

protected
clear()

clear without resolve Timer.aborted

ref()

makes the process not continue to run as long as the timer exists

abstract
run(): number

runs the timer

makes the process not continue to run as long as the timer exists