Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
stream-combiner2
Advanced tools
This is a sequel to [stream-combiner](https://npmjs.org/package/stream-combiner) for streams3.
The stream-combiner2 npm package allows you to combine multiple streams into a single stream. This is particularly useful for creating complex data processing pipelines where data flows through multiple transformations.
Combining multiple streams
This code demonstrates how to combine a readable stream, a transform stream, and a writable stream using stream-combiner2. The readable stream generates data, the transform stream modifies the data, and the writable stream outputs the final result.
const combine = require('stream-combiner2');
const { Readable, Transform, Writable } = require('stream');
const readable = new Readable({
read() {
this.push('data');
this.push(null);
}
});
const transform = new Transform({
transform(chunk, encoding, callback) {
this.push(chunk.toString().toUpperCase());
callback();
}
});
const writable = new Writable({
write(chunk, encoding, callback) {
console.log(chunk.toString());
callback();
}
});
const combinedStream = combine(readable, transform, writable);
combinedStream.on('finish', () => console.log('Stream processing completed.'));
The multipipe package also allows you to combine multiple streams into a single stream. It is similar to stream-combiner2 but offers a slightly different API. Both packages are used for creating stream pipelines, but multipipe is known for its simplicity and ease of use.
The pump package is another alternative for combining streams. It focuses on handling stream errors and cleanup, making it a robust choice for stream management. While stream-combiner2 is more focused on combining streams, pump provides additional features for error handling and resource management.
The mississippi package is a collection of useful stream utility functions, including a method for combining streams. It offers a more comprehensive set of tools for working with streams compared to stream-combiner2, which is specialized in stream combination.
This is a sequel to stream-combiner for streams3.
var combine = require('stream-combiner2')
Turn a pipeline into a single stream. Combine
returns a stream that writes to the first stream
and reads from the last stream.
Streams1 streams are automatically upgraded to be streams3 streams.
Listening for 'error' will recieve errors from all streams inside the pipe.
var Combine = require('stream-combiner')
var es = require('event-stream')
Combine( // connect streams together with `pipe`
process.openStdin(), // open stdin
es.split(), // split stream to break on newlines
es.map(function (data, callback) { // turn this async function into a stream
var repr = inspect(JSON.parse(data)) // render it nicely
callback(null, repr)
}),
process.stdout // pipe it to stdout !
)
MIT
FAQs
This is a sequel to [stream-combiner](https://npmjs.org/package/stream-combiner) for streams3.
The npm package stream-combiner2 receives a total of 2,642,065 weekly downloads. As such, stream-combiner2 popularity was classified as popular.
We found that stream-combiner2 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.