Share your code.
A stopwatch and countdown clock module for node.js
npm install timer-stopwatch
The Gist new Stopwatch([countDownMS], [options])
var Stopwatch = ;var timer = 60000; // A new countdown timer with 60 secondsvar stopwatch = ; // A new count up stopwatch. Starts at 0.
// 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;
timerstart;timer;timer; // Toggles the running statetimer; // optional countDownMS to reset countdown to that many milliseconds
timerms; // Number of milliseconds on the clock
var options =refreshRateMS: 10 // How often the clock should be updatedalmostDoneMS: 10000 // When counting down - this event will fire with this many milliseconds remaining on the clockvar timer = 60000 options;
Breaking Changes in v0.2
- The 'forcestop' event is being depreciated in favour of 'stop'.
- Use the onTime, onAlmostDone, onDone and onStop methods in favour of .on('eventname').
Unit and Integration tests (requires dev dependencies)