Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@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,326 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.