1.1.5 • Published 1 month ago

@resreq/timer v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Timer

version workflow download JavaScript Style Guide

⏰ Short and sweet timer based on requestAnimationFrame API

Install

npm install @resreq/timer

Usage

import Timer from '@resreq/timer'

const log = (time: number) => console.log('time:', time)

const timer = new Timer(log, {
  delay: 1000,
  immediate: true
})

timer.on('start', (time) => {
  console.log('start:', time)
})
timer.on('pause', (time) => {
  console.log('pause:', time)
})
timer.on('stop', (time) => {
  console.log('stop:', time)
})

timer.start()

setTimeout(() => timer.pause(), 1000)
setTimeout(() => timer.start(), 2000)
setTimeout(() => timer.stop(), 3000)

// => start: 1712160512855
// => time: 1712160512858
// => pause: 1712160513855
// => start: 1712160514855
// => time: 1712160514855
// => stop: 1712160515855

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

1.1.5

1 month ago

1.1.4

1 month ago

1.1.3

1 month ago

1.1.1

1 month ago

1.1.2

1 month ago

1.1.0

1 month ago

1.0.0

1 month ago