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

@types/p-queue

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/p-queue

Stub TypeScript definitions entry for p-queue, which provides its own types definitions

  • 3.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
93K
decreased by-64.49%
Maintainers
1
Weekly downloads
 
Created

What is @types/p-queue?

@types/p-queue provides TypeScript type definitions for the p-queue package, which is a promise queue with concurrency control. It allows you to manage the execution of asynchronous tasks, ensuring that a specified number of tasks run concurrently.

What are @types/p-queue's main functionalities?

Basic Queue Usage

This feature demonstrates how to create a basic queue with a concurrency of 1, meaning tasks will be executed one at a time.

const PQueue = require('p-queue');
const queue = new PQueue({ concurrency: 1 });

queue.add(() => Promise.resolve('Task 1')).then(console.log);
queue.add(() => Promise.resolve('Task 2')).then(console.log);

Concurrency Control

This feature demonstrates how to set a concurrency of 2, allowing two tasks to run concurrently.

const PQueue = require('p-queue');
const queue = new PQueue({ concurrency: 2 });

queue.add(() => new Promise(resolve => setTimeout(() => resolve('Task 1'), 1000))).then(console.log);
queue.add(() => new Promise(resolve => setTimeout(() => resolve('Task 2'), 500))).then(console.log);
queue.add(() => new Promise(resolve => setTimeout(() => resolve('Task 3'), 300))).then(console.log);

Queue Pause and Resume

This feature demonstrates how to pause and resume the queue. Tasks added while the queue is paused will wait until the queue is resumed.

const PQueue = require('p-queue');
const queue = new PQueue({ concurrency: 1 });

queue.add(() => Promise.resolve('Task 1')).then(console.log);
queue.pause();
queue.add(() => Promise.resolve('Task 2')).then(console.log);
queue.add(() => Promise.resolve('Task 3')).then(console.log);
setTimeout(() => queue.start(), 2000);

Other packages similar to @types/p-queue

FAQs

Package last updated on 04 Mar 2019

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