Small countdown timer and stopwatch module.
npm:
$ npm install tiny-timerYarn:
$ yarn add tiny-timerconst Timer = require('tiny-timer')
const timer = new Timer()
timer.on('tick', (ms) => console.log('tick', ms))
timer.on('done', () => console.log('done!'))
timer.on('statusChanged', (status) => console.log('status:', status))
timer.start(5000) // run for 5 secondsOptionally set the refresh interval in ms, or stopwatch mode instead of countdown.
Starts timer running for a duration specified in ms.
Optionally override 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().
Event emitted when the timer status changes.
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.