1.0.0 • Published 8 years ago
min-timer v1.0.0
min-timer
simple timer for javascript without pain in setInterval
Installation
npm i min-timer
inspired by as3 timer
var Timer = require('min-timer')
var timer = new Timer(1000, 5)
timer.start()
timer.on('timer', function() {
console.log('timer', timer.currentCount)
})
Api
Constructor
new Timer(interval, [repeatCount = Infinity])
Property
interval
interval set in constructorrepeatCount
total count set in constructorcurrentCount
current countrunning
is timer running
Method
start()
start timerstop()
stop timerreset()
stop and set currentCount = 0
Event
timer
when one interval passtimerComplete
timer complete
Static Method
sugar for timer, always auto start, and return the timer instance
Timer.interval(fn, interval, [repeatCount = Infinity])
Timer.timeout(fn, delay)
var timer = Timer.interval(function() {
console.log('timer interval', timer.currentCount)
}, 500, 5)
License
1.0.0
8 years ago