Initializes a new instance of the StopWatch class, optionally passing a configuration object as parameter.
An object with the options to configure the timer execution and output.
Gets the time span with the elapsed time so far, minus the paused time.
Gets a value representing the end time, in nanoseconds.
Gets whether or not the time counting has ended.
Gets the number of finished laps in the stopwatch.
Gets all time span objects containing the lap time count results.
Gets a value representing the last time the object resumed from a pause, in nanoseconds.
Gets the output options object used by this timer.
Gets whether or not the time counting is paused.
Gets the result time span object from the time counting.
Gets a value representing the start time, in nanoseconds.
Gets whether or not the time counting has started.
Gets a value representing the total paused time, in nanoseconds.
Finishes the time counting (including the lap), adjusting the time values and properties accordingly.
Finishes the current lap, adding the results to this object's result list.
Gets the timer total timespan, including the time it was paused.
A timespan object with the total time of the object.
Pauses the time counting.
Resumes the time counting from a paused state.
Protected setter for the endTime property.
Protected setter for the result property.
Protected setter for the startTime property.
Starts the time counting, also starting the first lap.
Generated using TypeDoc
Represents an extension of the timer object that allows time divisions (laps) during the counting.
Counting parcial times
import {StopWatch} from "timecount"; const sw = new StopWatch({ autoStart: true, precision: 4 }); while (doingSomething) { // Something that takes time sw.endLap(); } sw.end(); for (const lap of sw.lapResults) { console.log(`Lap parcial: ${lap.toString()}`); } console.log(`Total time: ${sw.result.toString()}`);