1.0.1 • Published 8 months ago

@brugmanjoost/stopwatch v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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);
1.0.1

8 months ago

1.0.0

8 months ago