0.0.5 • Published 1 year ago

worker-tick v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

worker-tick

npm version npm downloads bundle JSDocs License

Make setTimeout() and setInterval() timers work stably in background tabs (unfocused browser tabs)

Browsers reduce the frequency of setTimeout() and setInterval() when a browser tab is inactive (e.g., loses focus, switches to another tab, or switches to another application) for performance optimization reasons requestAnimationFrame() does the same thing

Install

Using npm:

npm install worker-tick

Usage

Refer to development in the repository

import workerTick from 'worker-tick'

- window.setInterval(console.log, 1000, 1, 2, 3)
+ workerTick.setInterval(console.log, 1000, 1, 2, 3)
// => Printouts per second: 1 2 3

// clear
const timerId = workerTick.setInterval(console.log, 1000, 1, 2, 3)
workerTick.clearInterval(timerId)

// setTimeout() Same as above

License

MIT License © 2024-PRESENT Lete114

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago