gus-stopwatch

1.0.1 • Public • Published

NodeJS module to handle a stopwatch a simple way

tested with jest jest

Ok, well I developped this simple stopwatch module cause I needed it. It is pretty usefull if you need to handle a stopwatch easily.

npm

npm install gus-stopwatch

usage

    const sw = require('gus-stopwatch');
    const stopwatch = new sw();

    //start takes an optional callback that is executed at each additional second. Pretty useful to update view or something
    stopwatch.start(() => console.log("one more second"));

    //well.. this stops the stopwatch. 
    stopwatch.stop();

    //reset stopwatch to zero and initial state
    stopwatch.reset();

    //return true if stopwatch is currently running
    stopwatch.isRunning() 

    //return current time in seconds
    stopwatch.getTime()

    //return datetime at which stopwatch was started
    stopwatch.getStartTime()

    //return datetime at which stopwatch was stopped.
    //caution, it must have been stopped, of course
    stopwatch.getEndTime() 

    //return a cool string display of the stopwatch
    // something like => 'mm:ss'
    stopwatch.getTimeString();

Readme

Keywords

none

Package Sidebar

Install

npm i gus-stopwatch

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

4.95 kB

Total Files

5

Last publish

Collaborators

  • guillaumegustin