Timeoutclass

new Timeout(callback: Callback | undefined = undefined, ms = 0)
ParamType
callbackCallback
A callback is a function that is called when something happens, optionally with multiple values. Defaults to undefined
msunknown
Defaults to 0
Return
Timeout
Stateful wrapper around setTimeout() that manages a single pending timeout at a time.
PropertyType
.existsboolean
Whether a timeout is currently pending. required readonly

Stateful wrapper around setTimeout() that manages a single pending timeout at a time.

  • Keeps track of the reference returned from setTimeout().
  • Clears any existing timeout when a new timeout is set.
  • Allows a default callback and a default delay to be set that are applied to all new timeouts that don't specify their own.

Methods

Go

Timeout.set()method

Cancel any existing timeout and set a new one.

set(callback: Callback | undefined = this._callback, ms: number = this._ms): void
Go

Timeout.clear()method

Cancel any existing timeout.

clear(): void