Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents an extension of the timer object that allows time divisions (laps) during the counting.

example

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()}`);

Hierarchy

Index

Constructors

constructor

Accessors

elapsedTime

elapsedTime:

Gets the time span with the elapsed time so far, minus the paused time.

endTime

endTime:

Gets a value representing the end time, in nanoseconds.

ended

ended:

Gets whether or not the time counting has ended.

lapCount

lapCount:

Gets the number of finished laps in the stopwatch.

lapResults

lapResults:

Gets all time span objects containing the lap time count results.

lastResumeTime

lastResumeTime:

Gets a value representing the last time the object resumed from a pause, in nanoseconds.

options

options:

Gets the output options object used by this timer.

paused

paused:

Gets whether or not the time counting is paused.

result

result:

Gets the result time span object from the time counting.

startTime

startTime:

Gets a value representing the start time, in nanoseconds.

started

started:

Gets whether or not the time counting has started.

totalPauseTime

totalPauseTime:

Gets a value representing the total paused time, in nanoseconds.

Methods

end

  • Finishes the time counting (including the lap), adjusting the time values and properties accordingly.

    Returns TimeSpan

endLap

  • Finishes the current lap, adding the results to this object's result list.

    Returns TimeSpan

getTimeIncludingPaused

pause

  • pause(): void

resume

  • resume(): number

Protected setEndTime

  • setEndTime(value: number): void

Protected setResult

Protected setStartTime

  • setStartTime(value: number): void

start

  • start(): void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc