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

d3-queue

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-queue

A minimalist approach to escaping callback hell.

  • 1.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126K
decreased by-50.52%
Maintainers
1
Weekly downloads
 
Created

What is d3-queue?

The d3-queue npm package is a utility for managing asynchronous tasks with a focus on concurrency control. It allows you to queue up tasks and control how many of them run simultaneously, making it easier to handle multiple asynchronous operations without overwhelming the system.

What are d3-queue's main functionalities?

Queue Creation

This feature allows you to create a new queue instance. The queue can then be used to manage multiple asynchronous tasks.

const queue = require('d3-queue').queue;
const q = queue();

Adding Tasks

This feature allows you to add tasks to the queue. Each task is a function that takes a callback as its argument. The callback should be called when the task is complete.

q.defer((callback) => {
  setTimeout(() => {
    console.log('Task 1 complete');
    callback(null, 'Task 1 result');
  }, 1000);
});

q.defer((callback) => {
  setTimeout(() => {
    console.log('Task 2 complete');
    callback(null, 'Task 2 result');
  }, 500);
});

Concurrency Control

This feature allows you to control the number of tasks that can run concurrently. By default, the concurrency is set to 1, but you can specify a different number when creating the queue.

const q = queue(2); // Allow up to 2 tasks to run concurrently

Awaiting Completion

This feature allows you to specify a callback that will be called when all tasks in the queue have completed. The callback receives any error that occurred and an array of results from the tasks.

q.awaitAll((error, results) => {
  if (error) throw error;
  console.log('All tasks complete', results);
});

Other packages similar to d3-queue

Keywords

FAQs

Package last updated on 29 Jan 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