worker-timer

Timer API that works stable in background tabs

Usage no npm install needed!

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

README

worker-timer

Build Status NPM Version License

Timer API that works stable in background tabs

Installation

npm install worker-timer

downloads:

API

  • setInterval(callback: function, delay: number, ...params: any): number
  • clearInterval(timerId: number): void
  • setTimeout(callback: function, delay: number, ...params: any): number
  • clearTimeout(timerId: number): void

Example

Same as the native Timer API

const WorkerTimer = require("worker-timer");

let count = 0;

WorkerTimer.setInterval(() => {
  count += 1;
  console.log("count: " + count);
}, 1000);

License

MIT