Socket
Book a DemoInstallSign in
Socket

request-animation-frames

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-animation-frames

Use requestAnimationFrame as an async iterable, in any JavaScript environment

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
536
-28.25%
Maintainers
1
Weekly downloads
 
Created
Source

request-animation-frames

Use requestAnimationFrame as an async iterable, in any JavaScript environment

This package ponyfills requestAnimationFrame internally when not available, so it works in any JavaScript environment.

Install

npm install request-animation-frames

Usage

import requestAnimationFrames from 'request-animation-frames';

for await (const timestamp of requestAnimationFrames()) {
	console.log('Animation frame timestamp:', timestamp);
	drawVisualization();
}

API

requestAnimationFrames()

Returns an AsyncIterable that yields animation frame timestamps.

FAQ

How do I stop the loop?

Simply return or break in the loop.

How do I stop the loop from the outside?

import requestAnimationFrames from 'request-animation-frames';

let shouldStop = false;

(async () => {
	for await (const timestamp of requestAnimationFrames()) {
		if (shouldStop) {
			break;
		}

		console.log('Animation frame timestamp:', timestamp);
	}
})();

setTimeout(() => {
	shouldStop = true;
}, 10000);

Keywords

requestAnimationFrame

FAQs

Package last updated on 21 Nov 2023

Did you know?

Socket

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.

Install

Related posts