1.0.22 • Published 4 years ago

tiny-stopwatch v1.0.22

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

What does it do?

It measueres time passed since moment of its initialization. In seconds, because we are humans.

Why?

To avoid annoying missing/duplicated labels errors and inconvenient syntax when triggering console.time() and console.timeEnd() in async JS code. Since I'm using this tiny snippet in many projects it's better to keep it - and share - as a separated package.

How?

install:

yarn add tiny-stopwatch

or

npm i tiny-stopwatch

then:

import TinyStopwatch from "tiny-stopwatch";
// or const TinyStopwatch = require('tiny-stopwatch');

console.log("Big Bang!");
const timer = new TinyStopwatch(); // creating instance initializes stopwatch

//
// some time consuming stuff
//

console.log("Time passed since Big Bang!: " + timer.getInterval() + "s");

//
// another time consuming stuff
//

console.log("Time passed since Big Bang!: " + timer.getInterval() + "s");

console.log("Big Bang, once again!");
timer.reset(); // reinitializes stopwatch
1.0.22

4 years ago

1.0.21

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago