Skip to content

enjoyjs/stopwatch

Repository files navigation

stopwatch

A stopwatch utility

Install

npm i @enjoyjs/stopwatch

Then import this:

import { Stopwatch } from '@enjoyjs/stopwatch';

API

class: Stopwatch

const stopwatch = new Stopwatch();

Alternatively, you can use the current high resolution millisecond timestamp:

import { performance } from 'perf_hooks';

const stopwatch = new Stopwatch(performance.now);

stopwatch.start()

stopwatch.pause()

stopwatch.reset()

stopwatch.isRunning()

stopwatch.getTime()

stopwatch.lap()

stopwatch.getLapTimes()

License

This package is licensed under the MIT License.