@brugmanjoost/stopwatch

1.0.1 • Public • Published

stopwatch

A simple stopwatch for checking durations.

1. Installation

$ npm install @brugmanjoost/stopwatch

2. Usage

const Stopwatch = require('@brugmanjoost/stopwatch');

let stopwatch = new Stopwatch();
stopwatch.start();

let i = setInterval(() => {
    console.log(`${stopwatch.duration}ms has passed`);
}, 500);

setTimeout(() => {
    console.log(`Stopping stops the counter. Duration is preserved.`);
    stopwatch.stop();
}, 3000);

setTimeout(() => {
    console.log(`Starting again continues the counter.`);
    stopwatch.start();
}, 4500);

setTimeout(() => {
    console.log(`Resetting sets the duration back to 0.`);
    stopwatch.reset();
}, 6000);

setTimeout(() => {
    console.log(`That's all there is.`);
    clearInterval(i);
}, 8000);

Readme

Keywords

Package Sidebar

Install

npm i @brugmanjoost/stopwatch

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

3.23 kB

Total Files

4

Last publish

Collaborators

  • brugmanjoost