Skip to main content
Module

x/timers/mod.ts>Timer

All timing functions you need - long and async timeouts, intervals, promise timeouts and more
Latest
class Timer
Abstract
import { Timer } from "https://deno.land/x/timers@v0.2.3/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: boolean

A boolean value that indicates whether the timer has been aborted

readonly
options: TimerOptions<T>
readonly
persistent: boolean

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

readonly
running: boolean

Indicates whether the timer is currently running

deprecated
readonly
timer: number

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