Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-timer

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-timer

An efficient queue capable of managing thousands of concurrent animations.

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9M
decreased by-24.96%
Maintainers
1
Weekly downloads
 
Created

What is d3-timer?

The d3-timer package provides a set of tools for controlling the timing of animations, transitions, and other time-based operations. It allows for the efficient scheduling of new timers, the creation of timer queues, and the handling of elapsed time within scheduled callbacks.

What are d3-timer's main functionalities?

Creating and starting a timer

This feature allows you to create a new timer that calls a specified callback function on each animation frame with the elapsed time. The timer can be stopped by calling the stop method.

const timer = d3.timer(elapsed => {
  console.log('Timer elapsed time:', elapsed);
  if (elapsed > 2000) timer.stop();
});

Creating a timer with a delay and time limit

This feature allows you to create a timer with a delay before it starts invoking the callback function. The timer will automatically stop after a specified time limit.

const timer = d3.timer(elapsed => {
  console.log('Timer elapsed time with delay:', elapsed);
  if (elapsed > 1000) timer.stop();
}, 500);

Creating a timer queue

This feature allows you to create a queue of timers that will execute their callback functions after a specified delay. It is similar to using setTimeout but is integrated with the d3-timer's efficient timing mechanism.

const timer1 = d3.timeout(() => console.log('Timeout 1'), 1000);
const timer2 = d3.timeout(() => console.log('Timeout 2'), 2000);

Creating an interval timer

This feature allows you to create a timer that will execute its callback function at a specified interval. It is similar to using setInterval but provides more accurate and efficient timing.

const interval = d3.interval(() => {
  console.log('Interval tick');
  if (++count > 10) interval.stop();
}, 1000);

Other packages similar to d3-timer

Keywords

FAQs

Package last updated on 22 Feb 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc