Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
async-queue-stream
Advanced tools
Wrapper for through stream to use async.queue under the hood.
It takes an asynchronous function and queue stream chunks. Then the queue executes the asynchronous function up to the concurrency threshold.
Any error will be emitted to opts.error_event
event. By default, the stream will not stop on error; this can be configured via opts.stop_on_error
.
Install Node.js
Run: npm install async-queue-stream
Arguments
write_fn(data, callback)
- an asnynchronous function that will be wrapped into a through stream
data
is the queued stream chunk.
There are three ways to invoke callback:
callback(null, transformedData)
- emit datacallback(error)
- emit errorcallback()
- drop data (don't emit to next stream)end_fn()
- a function that will be invoked when no more data will be provided.
options
- an object containing options
options.concurrency
- concurrency argument to async.queue. Default: 1
options.error_event
- event name used to emit the error from callback via the asynchronous function. Default: 'failure'
options.stop_on_error
- boolean value for asyncqueue
to stop queuing any more stream chunks if callback via the asynchronous function has emitted an error. Default: false
Note: Any tasks already executed will be able to complete.
var es = require('event-stream');
var qasync = require('queue-async-stream');
// something that returns stream using queue-async-stream internally
var plugin = function(filter, filter_func) {
if(filter_func == void 0)
filter_func = function(n) { return n; };
return qasync(function (data, cb) {
if(filter_func(data) == filter) {
setTimeout(function() {
return cb(new Error(filter+''));
}, 1000);
return;
}
if(data === 2) {
setTimeout(function() {
return cb(null, data);
}, 2000);
return;
}
console.log('caught in plugin: ' + data)
return cb(null, data);
}, {concurrency: 2});
};
es.readArray([1,2,3,4,5])
.pipe(plugin(3))
.on('failure', console.log)
.pipe(es.through(function(n) {
console.log('caught in es.through: ' + n);
this.emit('data', n);
}));
/**
Output:
caught in plugin: 1
caught in es.through: 1
[Error: 3]
caught in plugin: 4
caught in es.through: 4
caught in plugin: 5
caught in es.through: 5
caught in es.through: 2
With stop_on_error:true, output is:
caught in plugin: 1
caught in es.through: 1
[Error: 3]
caught in es.through: 2
*/
MIT. See LICENSE file.
FAQs
Stream using async.queue under the hood.
We found that async-queue-stream 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.