Options
All
  • Public
  • Public/Protected
  • All
Menu

A simple and smart wrapper around NodeJS.Timeout

Hierarchy

  • Timer

Constructors

Protected constructor

Creates a new timer, does not start until start method is called.

Parameters

Returns Timer

Methods

addCallback

Add a callback for when this Timer reaches end.

Parameters

Returns this

This Timer.

asAwaitable

  • asAwaitable(): Promise<void>

Returns the awaitable so you can use this Timer more asynchronously. !(DANGER) Do not await a stopped Timer, you will be waiting a long time (i.e. forever). ? Maybe this should make it auto start if it's not already running?

Returns Promise<void>

Promise that will resolve when Timer reaches end.

reset

  • reset(): this

Resets the Timer and starts it. *(WARNING) This method cannot be used in tests as Jest mocks timeouts based on browser specs. They claim changing the testEnv to node fixes it, but it still doesn't recognize the timeout.refresh() as a method that exists.

Returns this

This currently running Timer.

start

  • start(): this

Starts the Timer from the beginning if it's not running, or does nothing if already running.

Returns this

This currently running Timer.

stop

  • stop(): this

Stops the Timer, or does nothing if Timer is already stopped.

Returns this

This currently stopped Timer.

Static for

Creates a new timer, does not start until start method is called.

Parameters

Returns Timer

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.