![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@types/p-queue
Advanced tools
Stub TypeScript definitions entry for p-queue, which provides its own types definitions
@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.
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);
The async package provides various functions for working with asynchronous JavaScript, including queue management. It offers more utilities beyond just queue management, such as parallel execution, series execution, and more.
The promise-queue package is a lightweight promise queue with concurrency control. It is similar to p-queue but with a simpler API and fewer features.
Bottleneck is a powerful rate limiter that also provides queue functionality. It allows you to control the rate of task execution, making it suitable for scenarios where you need to limit the rate of API calls or other operations.
This is a stub types definition for p-queue (https://github.com/sindresorhus/p-queue).
p-queue provides its own type definitions, so you don't need @types/p-queue installed!
FAQs
Stub TypeScript definitions entry for p-queue, which provides its own types definitions
The npm package @types/p-queue receives a total of 49,680 weekly downloads. As such, @types/p-queue popularity was classified as popular.
We found that @types/p-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.