Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
audio-context-timers
Advanced tools
A replacement for setInterval() and setTimeout() which works in unfocused windows.
A replacement for setInterval() and setTimeout() which works in unfocused windows.
For scripts that rely on WindowTimers like setInterval() or setTimeout() things get confusing when the site which the script is running on loses focus. Chrome, Firefox and maybe others throttle the frequency at which they invoke those timers to a maximum of once per second in such a situation. However it is possible to schedule AudioBufferSourceNodes and listen for their onended
event to achieve a similar result. This makes it possible to avoid the throttling.
audio-context-timers
is available as a package on npm. Run the following command to install it:
npm install audio-context-timers
You can then import the exported functions in your code like this:
import { clearInterval, clearTimeout, setInterval, setTimeout } from 'audio-context-timers';
The usage is exactly the same as with the corresponding functions on the global scope.
var intervalId = setInterval(() => {
// do something many times
}, 100);
clearInterval(intervalId);
var timeoutId = setTimeout(() => {
// do something once
}, 100);
clearTimeout(timeoutId);
However there are some subtle differences between audio-context-timers
and WindowTimers which are the same those of the worker-timers
package.
FAQs
A replacement for setInterval() and setTimeout() which works in unfocused windows.
The npm package audio-context-timers receives a total of 168 weekly downloads. As such, audio-context-timers popularity was classified as not popular.
We found that audio-context-timers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.