Skip to main content

Class: Stopwatch

Defined in: index.ts:4

Stopwatch class, uses native node to replicate/extend performance-now dependency.

Constructors

new Stopwatch()

new Stopwatch(digits: number): Stopwatch

Defined in: index.ts:23

Starts a new stopwatch

Parameters

ParameterTypeDefault value
digitsnumber2

Returns

Stopwatch

Properties

#end

private #end: null | number

Defined in: index.ts:18

The end time of this stopwatch


#start

private #start: number

Defined in: index.ts:13

The start time of this stopwatch


digits

digits: number

Defined in: index.ts:8

The number of digits to appear after the decimal point when returning the friendly duration.

Accessors

duration

Get Signature

get duration(): number

Defined in: index.ts:32

The duration of this stopwatch since start or start to end if this stopwatch has stopped.

Returns

number


running

Get Signature

get running(): boolean

Defined in: index.ts:39

If the stopwatch is running or not.

Returns

boolean

Methods

reset()

reset(): this

Defined in: index.ts:55

Resets the Stopwatch to 0 duration (Returns a stopped state)

Returns

this


restart()

restart(): this

Defined in: index.ts:46

Restarts the stopwatch (Returns a running state)

Returns

this


start()

start(): this

Defined in: index.ts:64

Starts the Stopwatch

Returns

this


stop()

stop(): this

Defined in: index.ts:76

Stops the Stopwatch, freezing the duration

Returns

this


toString()

toString(): string

Defined in: index.ts:84

Defines toString behavior

Returns

string