
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
mini-queue
Advanced tools
Job queue
If you have different needs regarding the functionality, please add a feature request.
npm install --save mini-queue
QueueJob State Diagram (methods of JobQueue object)
======================
|
createJob |
+------V-----+
| new |
| |
+---+--+--+--+
| | | _rejectJob +------------+
| | +--------------------------------> reject |
| | | |
_startJob | | _queueJob +------------+
| +------------+
| |
| +-----v------+ _cancelJob
| | queue +-----------------+
| | | |
| +---+----^---+ |
| _dequeueJob | | |
| | | |
| | | _queueJob |
| +---v----+---+ _cancelJob +-V----------+
| | dequeue +---------------> cancel |
| | | | |
| +-----+------+ +------------+
| | _startJob
| |
| +----------+
| |
+---v----v---+ _terminateJob +------------+
| process +----------------------> terminate |
| | |(not implem)|
+-----+------+ +------------+
|
|
|
+-----v------+
| complete |
| |
+------------+
You may find this example in demo
subdirectory of the package.
"use strict";
process.env.DEBUG = 'queue,app';// + (process.env.DEBUG || '');
var debug = require('debug')('app');
var Queue = require('express-queue');
//var Queue = require('../');
var queue = new Queue({ activeLimit: 1, queuedLimit: 1 });
// create jobs
var maxCount = 5,
count = 0;
var interval = setInterval(function() {
var jobData = {};
// Create new job for the queue
// If number of active job is less than `activeLimit`, the job will be started on Node's next tick.
// Otherwise it will be queued.
queue.createJob(jobData); // we may pass some data to job when calling queue.createJob() function
if (++count >= maxCount) {
clearInterval(interval);
}
}, 500);
// execute jobs
queue.on('process', function(job, jobDone) {
debug('queue.on(\'process\'): ['+job.id+']');
// Here the job starts
// Imitate job processing which takes 1 second to be finished
// job.data is set to value passed to queue.createJob()
setTimeout(function() {
// Call the callback to signal to the queue that the job has finished
// and the next one may be started
jobDone();
// Now on Node's next tick the next job (if any) will be started
}, 1000);
});
// Signal about jobs rejected due to queueLimit
queue.on('reject', function(job) {
debug('queue.on(\'reject\'): ['+job.id+']');
});
github.com npmjs.com travis-ci.org coveralls.io inch-ci.org
MIT
FAQs
Job queue
The npm package mini-queue receives a total of 8,156 weekly downloads. As such, mini-queue popularity was classified as popular.
We found that mini-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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.