{"library":"raf","title":"raf - requestAnimationFrame polyfill","description":"The `raf` package provides a `requestAnimationFrame` polyfill, making the browser animation API available in non-browser environments like Node.js and ensuring broader compatibility across older browser versions. The current stable version is 3.4.1. It maintains a simple, direct API for scheduling animation callbacks, distinct from event emitter or stream-based approaches which were moved to the separate `raf-stream` package in versions prior to 1.0.0. Its primary differentiator is its lightweight nature and dedicated support for Node.js environments without relying on heavy browser emulation. Release cadence is infrequent, typical for a stable polyfill, with updates primarily addressing compatibility issues or minor bug fixes, rather than introducing new features. This package is a foundational utility for cross-environment animation loops.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install raf"],"cli":null},"imports":["import raf from 'raf';","const raf = require('raf');","import 'raf/polyfill';","window.raf(...);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import raf from 'raf';\n\nlet frameCount = 0;\nconst maxFrames = 100;\n\nconsole.log('Starting animation loop...');\n\nfunction animate() {\n  // Perform animation logic here\n  console.log(`Processing animation frame: ${frameCount}`);\n  frameCount++;\n\n  if (frameCount < maxFrames) {\n    raf(animate); // Schedule the next frame\n  } else {\n    console.log('Animation finished after', maxFrames, 'frames.');\n  }\n}\n\n// Start the initial animation frame\nraf(animate);\n","lang":"javascript","description":"Demonstrates a basic animation loop using `raf` to schedule a function (`animate`) to run on subsequent animation frames, logging progress until a predefined frame limit is reached.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}