Small countdown timer and stopwatch module.
npm install tiny-timer

!downloads


Small countdown timer and stopwatch module.
shell
$ npm install tiny-timer
`
Yarn:
`shell
$ yarn add tiny-timer
`Example
`javascript
const 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 seconds
`Usage
$3
Optionally set the refresh interval in ms, or stopwatch mode instead of countdown.$3
Starts timer running for a duration specified in ms.
Optionally override the default refresh interval in ms.$3
Stops timer.$3
Pauses timer.$3
Resumes timer.Events
$3
Event emitted every interval with the current time in ms.$3
Event emitted when the timer reaches the duration set by calling timer.start().$3
Event emitted when the timer status changes.Properties
$3
Gets the current time in ms.$3
Gets the total duration the timer is running for in ms.$3
Gets the current status of the timer as a string: running, paused or stopped`.