duck-timer
v1.0.3
Published
A helpful timer class for both of browsers and node.js.
Downloads
141
Readme
DuckTimer
A helpful timer class for both of browsers and node.js.
Installation
npm install duck-timer
Usage
Stopwatch
import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 100 }); // interval time: 100ms = 0.1sec.
// start.
timer.onInterval(res => {
console.log(res.seconds);
}).start();
// stop.
timer.stop();
// reset.
timer.reset();
Countdown
import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 1000 });
timer.setCountdown(`Dec 25, ${new Date().getFullYear()}`)
.onInterval(res => console.log(res.remain.seconds))
.onTimeout(() => console.log('Merry Christmas!!!'))
.start();
API
Please see DuckTimer API.