An efficient queue for managing thousands of concurrent animations with consistent, synchronized timing. Version 3.0.1 (stable) uses requestAnimationFrame for fluid animation when available, falling back to setTimeout for delays >24ms. Unlike raw setInterval or setTimeout, d3-timer provides frame-level synchronization, automatic pause during page backgrounding, and guaranteed callback order within frames. Part of the D3 ecosystem, it is also usable standalone via npm or CDN (ESM, UMD, or Skypack).
npm install d3-timerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a timer that logs elapsed time every frame, stops after 500ms, and shows current time via now().
Use dynamic import() or switch to ESM. For Node <12 or CJS, stay on v2.
Store the timer reference: const t = d3.timer(cb); t.stop();
Do not rely on elapsed for wall-clock accuracy during background tabs.
Remove flush() calls. For immediate execution, invoke callback directly or use setTimeout(fn, 0).
npm install d3-timer and use ESM import. For CJS, pin to v2: npm install d3-timer@2
Use ES module syntax or downgrade to d3-timer@2.
Always assign timer() return value: const t = d3.timer(cb); then t.stop().
No dependency data recorded yet.