1.1.1 • Published 3 years ago

ez-timer v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

ez-timer

npm dependencies downloads license

Get better accuracy on every tick compared to setInterval() method.

Installation

npm:

npm i ez-timer --save

Example Usage

import { Timer } from 'ez-timer';

const timer1 = new Timer(() => console.log('tick'), 1000);
const timer2 = new Timer();

timer1.start(); // start timer
timer1.stop(); // stop timer
timer2.start(10000, () => console.log('complete')); // run for 10 seconds

Usage

timer = new Timer(callback, interval, errorCallback)

  • Optionally set the callback function that will be trigged on every interval.
  • Optionally set the refresh interval in ms.
  • Optionally set the error callback function that will be trigged on error happened.

timer.start(duration, callback)

  • Starts timer running for a duration specified in ms.
  • Optionally set callback function that will be trigged on the timer end.

timer.stop()

  • Stops timer.
1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago