
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
ForkQueue creates a queue where the items are removed via a 'next' message received from child processes. The number of child processes is passed to the constructor along with the full path of the module to run. The processes are spawned via child_process.fork
var Queue = require('forkqueue');
var numWorkers = 5,
module = 'worker.js';
var queue = new Queue(numWorkers, module);
Add a value to the queue
for (var i = 0; i < 100; i++) {
queue.enqueue(i);
}
Puts the values of the array onto the queue
var vals = [];
for (var i = 0; i < 100; i++) {
vals.push(i);
}
queue.concat(vals);
Wait for the child processes to work through the queue then kill them.
queue.end(callback);
The Queue inherits from EventEmitter. It emits the following events:
queue.emit('msg', value)
- a value forwarded from a workerqueue.emit('error', error)
- an errorqueue.emit('enqueue', value)
- the enqueued valuequeue.emit('dequeue', value)
- the dequeued valuequeue.emit('concat', values)
- the list of values to enqueuequeue.emit('flush')
- the queue is trying to flush outstanding tasks to available workersWorker modules are spawned with child_process.fork. In order to request a value off the queue, they send a 'next' message to the parent with process.send('next')
. The only message sent to them contains the value off the queue. They will exit with 'SIGTERM' sent from the parent after queue.end
is called. They can also send arbitrary messages != 'next', that get emitted from the queue.
A simple worker is below.
process.send({msg: 'some string'});
process.on('message', function(value) {
// Do something with value
// Tell the parent to return the next value off the queue
process.send('next');
});
process.send('next');
FAQs
A queue that is dequeued by forked processes
The npm package forkqueue receives a total of 984 weekly downloads. As such, forkqueue popularity was classified as not popular.
We found that forkqueue 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.