timer-stopwatch
A stopwatch and countdown clock module for node.js
Install
npm install timer-stopwatch
How to
The Gist
new Stopwatch([countDownMS], [options])
Basic timers
var Stopwatch = require('timer-stopwatch');
var timer = new Stopwatch(60000);
var stopwatch = new Stopwatch();
###Event Methods
timer.onTime(function(time) {
console.log(time.ms);
});
timer.onDone(function(){
console.log('Timer is complete');
});
timer.onAlmostdone(function() {
console.log('Timer is almost complete');
});
timer.onTime(cb).onAlmostdone(cb).onDone(cb);
###Timer Methods
timer.start();
timer.stop();
timer.startstop();
timer.reset(countDownMS);
###Properties
timer.ms;
###Options
var options = {
refreshRateMS: 10,
almostDoneMS: 10000,
}
var timer = new Stopwatch(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').
Testing
Unit and Integration tests (requires dev dependencies)
npm test
License
MIT License