[go: up one dir, main page]

stopwatch-dev
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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.

Package Sidebar

Install

npm i stopwatch-dev

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

7.13 kB

Total Files

5

Last publish

Collaborators

  • mchl_bld