Create
Example
const Timer = require('nodetimer.js')
const timer = new Timer(
'5 seconds',
's',
() => { console.log("Timer is done!") },
(at) => { console.log(at) }
)
Params (in order)
endAt
The first parameter is endAt
. This is when the timer should stop. It can be in milliseconds or a string like 5 seconds
(powered by millisecond)
tickTime
The second option is tickTime
. This is how often it should tick. Options are ms
for once every millisecond or s
, once every second.
onEnd
The third param is onEnd
. This is a callback to run when the timer has completed.
() => { console.log('done') }
onTick
The final param is onTick
. This is a callback to run when the time elapses.
(at) => { console.log(`The timer is currently at ${at}!`) }
Last updated