small-timer

A count down util, support start pause resume restore methods

Usage no npm install needed!

<script type="module">
  import smallTimer from 'https://cdn.skypack.dev/small-timer';
</script>

README

SmallTimer

SmallTimer

import SmallTimer from "small-timer"

const timer = new SmallTimer(1000, 10)
timer.addEventListener(SmallTimer.TIMER, onTimer)
timer.addEventListener(SmallTimer.TIMER_COMPLETE, onComplete)
timer.start()
// timer.pause()
// timer.reset()

function onTimer(e) {
  console.log('timer current count:', e.currentCount)
  console.log('timer repeat count:', e.repeatCount)
  console.log('timer is running:', e.running)
}

function onComplete() {
  console.log('complete')
}