Skip to main content

Class: Stopwatch

@sapphire/stopwatch.Stopwatch

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

Constructors

constructor

โ€ข new Stopwatch(digits?)

Starts a new stopwatch

Parameters

NameTypeDefault value
digitsnumber2

Defined in

projects/utilities/packages/stopwatch/src/index.ts:27

Properties

#end

โ€ข Private #end: null | number

The end time of this stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:22


#start

โ€ข Private #start: number

The start time of this stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:16


digits

โ€ข digits: number

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

Defined in

projects/utilities/packages/stopwatch/src/index.ts:10

Accessors

duration

โ€ข get duration(): number

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

Returns

number

Defined in

projects/utilities/packages/stopwatch/src/index.ts:36


running

โ€ข get running(): boolean

If the stopwatch is running or not.

Returns

boolean

Defined in

projects/utilities/packages/stopwatch/src/index.ts:43

Methods

reset

โ–ธ reset(): Stopwatch

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

Returns

Stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:59


restart

โ–ธ restart(): Stopwatch

Restarts the stopwatch (Returns a running state)

Returns

Stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:50


start

โ–ธ start(): Stopwatch

Starts the Stopwatch

Returns

Stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:68


stop

โ–ธ stop(): Stopwatch

Stops the Stopwatch, freezing the duration

Returns

Stopwatch

Defined in

projects/utilities/packages/stopwatch/src/index.ts:80


toString

โ–ธ toString(): string

Defines toString behavior

Returns

string

Defined in

projects/utilities/packages/stopwatch/src/index.ts:88