Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
combine-stream
Advanced tools
Combine multiple duplex streams into just one.
combine-stream lets you treat a few streams as just one, in a parallel fashion. When you combine a bunch of streams, you write to it as if it was one, and read from it as if it was one, but you are simultaneously writing to all the streams and getting the output from all the streams.
Error events are also aggregated from all the streams and forwarded up through the combining stream for you to listen to in one place.
Code:
var stream = require("stream");
var CombineStream = require("combine-stream");
var streamA = new stream.PassThrough({objectMode: true}),
streamB = new stream.PassThrough({objectMode: true}),
streamC = new stream.PassThrough({objectMode: true});
var combine = new CombineStream([streamA, streamB, streamC]);
combine.on("data", console.log);
combine.write("hello");
combine.end();
Output:
hello
hello
hello
Available via npm:
$ npm install combine-stream
Or via git:
$ git clone git://github.com/deoxxa/combine-stream.git node_modules/combine-stream
NOTE:
Currently this is relying on my fork of readable-stream. Hopefully my patch gets merged and I can remove the hardcoded github dependency.
constructor
Creates a new combine-stream.
new CombineStream(options);
var combine = new CombineStream({
logSize: 100,
recordDuplicates: true,
comparator: functon compare(a, b) {
return a === b;
},
});
Arguments
TransformStream
options, the parameters described below. If this argument is an array, it will
be wrapped in {streams: ...}
.options
Also see example.js.
var stream = require("stream");
var CombineStream = require("combine-stream");
var delayed = function delayed(n) {
var s = new stream.Transform({objectMode: true});
s._transform = function _transform(input, encoding, done) {
var self = this;
return setTimeout(function() {
self.push(input + " " + n);
return done();
}, n);
};
s._flush = function _flush(done) {
console.log("ending!", n);
setTimeout(done, n);
};
return s;
};
var combine = new CombineStream();
var streamA = delayed(100),
streamB = delayed(500);
var combine = new CombineStream([streamA, streamB]);
combine.on("data", console.log);
combine.on("error", console.log);
combine.write("hello 1");
combine.write("hello 2");
combine.write("hello 3");
combine.end(function() {
console.log("everything finished");
});
Output:
hello 1 100
hello 1 500
hello 2 100
hello 2 500
hello 3 100
hello 3 500
ending! 100
ending! 500
everything finished
3-clause BSD. A copy is included with the source.
FAQs
Combine multiple duplex streams into just one
The npm package combine-stream receives a total of 181 weekly downloads. As such, combine-stream popularity was classified as not popular.
We found that combine-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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.