Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
better-queue
Advanced tools
better-queue is a simple and efficient job queue for Node.js. It allows you to manage and process tasks asynchronously, with features like priority handling, concurrency control, and job persistence.
Basic Queue
This code demonstrates how to create a basic queue and add tasks to it. The tasks are processed asynchronously.
const Queue = require('better-queue');
let q = new Queue(function (input, cb) {
console.log('Processing:', input);
cb(null, input);
});
q.push('Task 1');
q.push('Task 2');
Concurrency Control
This code shows how to set up a queue with concurrency control, allowing up to 2 tasks to be processed simultaneously.
const Queue = require('better-queue');
let q = new Queue(function (input, cb) {
console.log('Processing:', input);
setTimeout(() => cb(null, input), 1000);
}, { concurrent: 2 });
q.push('Task 1');
q.push('Task 2');
q.push('Task 3');
Priority Handling
This code demonstrates how to add tasks with different priorities to the queue. Higher priority tasks are processed first.
const Queue = require('better-queue');
let q = new Queue(function (input, cb) {
console.log('Processing:', input);
cb(null, input);
});
q.push('Low Priority Task', { priority: 10 });
q.push('High Priority Task', { priority: 1 });
Job Persistence
This code shows how to set up job persistence using an in-memory store. This allows tasks to be stored and retrieved even if the process is restarted.
const Queue = require('better-queue');
const Store = require('better-queue-memory');
let q = new Queue(function (input, cb) {
console.log('Processing:', input);
cb(null, input);
}, { store: new Store() });
q.push('Persistent Task');
Bull is a popular Redis-based queue for Node.js. It offers advanced features like job retries, rate limiting, and job scheduling. Compared to better-queue, Bull is more feature-rich and suitable for larger-scale applications that require persistent storage and advanced job management.
Kue is another Redis-based priority job queue for Node.js. It provides a simple API for creating, processing, and monitoring jobs. Kue is similar to better-queue in terms of ease of use but offers additional features like job event handling and a built-in UI for monitoring.
Bee-Queue is a high-performance Redis-based job queue for Node.js. It focuses on speed and simplicity, making it a good choice for applications that require fast job processing. Compared to better-queue, Bee-Queue is more performant but requires Redis for job storage.
Better Queue for NodeJS
Queues can be quite hard. There's a lot of cases to consider. Luckily, better-queue handles all of these cases!
FAQs
Better Queue for NodeJS
The npm package better-queue receives a total of 96,930 weekly downloads. As such, better-queue popularity was classified as popular.
We found that better-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
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.