Small countdown timer and stopwatch module.
npm install tiny-timer
const Timer = require('tiny-timer')
let timer = new Timer()
timer.on('tick', (ms) => console.log('tick', ms))
timer.on('done', () => console.log('done!'))
timer.start(5000) // run for 5 seconds
Optionally set the refresh interval
in ms, or stopwatch
mode instead of countdown.
Starts timer running for a duration
specified in ms.
Optionally overide the default refresh interval
in ms.
Stops timer.
Pauses timer.
Resumes timer.
Event emitted every interval
with the current time in ms.
Event emitted when the timer reaches the duration
set by calling timer.start()
.
Gets the current time in ms.
Gets the total duration
the timer is running for in ms.
Gets the current status of the timer as a string: running
, paused
or stopped
.