timer-stopwatch
A stopwatch and countdown clock module for node.js, maintained.
Install
npm install timer-stopwatch
How to
The Gist
countDownMS options;
Basic timers
var Stopwatch = ; var timer = 60000; // A new countdown timer with 60 secondsvar stopwatch = ; // A new count up stopwatch. Starts at 0.
Event Methods
// Fires every 50ms by default. Change setting the 'refreshRateMS' optionstimer; // Fires when the timer is donetimer; // Fires when the timer is almost complete - default is 10 seconds remaining. Change with 'almostDoneMS' optiontimer; //These methods are chainabletimer ;
Timer Methods
timerstart;timer;timer; // Toggles the running statetimer; // optional countDownMS to reset countdown to that many millisecondstimer // Return 0, 1 or 2 if the timer is respectively stopped, running or completetimertimertimer
Properties
timerms; // Number of milliseconds on the clocktimerseconds; // Number of seconds on the clock
Options
var options = refreshRateMS: 10 // How often the clock should be updated almostDoneMS: 10000 // When counting down - this event will fire with this many milliseconds remaining on the clock; var timer = 60000 options;
Testing
Unit and Integration tests (requires dev dependencies)
npm test
Thanks to
@MickCrozier - The maintainer of the original package.
Other contributors:
- @danhere
- @connorjburton
- @RafaelKaczmarczyk
- @nitzo
License
MIT License