1.0.2 • Published 1 year ago

stopwatch-dev v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Stopwatch

npm version

A simple stopwatch app that allows you to start, stop, and reset the timer. Intended to be used for timing functions calls in JavaScript/TypeScript.

Installation

npm install stopwatch-dev

Usage

import { Stopwatch } from "stopwatch-dev";

// create instance
const stopwatch = new Stopwatch();

// measure function call execution time
stopwatch.start();
expensiveFunction();
stopwatch.stop();

// get duration and access values...
const duration = stopwatch.duration();

const millies = stopwatch.millies();
const seconds = stopwatch.seconds();
const minutes = stopwatch.minutes();
const hours = stopwatch.hours();

// ... or get complete millieseconds
const totalMillies = stopwatch.duration();

// ... or print the duration
console.log(duration);
// prints: 1:23:45.678 (hours:minutes:seconds.millies)

Testing

To run the tests, use the following command:

pnpm test

Links

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago