Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
ordered-read-streams
Advanced tools
The ordered-read-streams npm package allows you to combine multiple readable streams into a single readable stream, ensuring that the data from each stream is read in the order the streams were provided. This can be particularly useful when you need to process multiple streams sequentially.
Combining Multiple Streams
This feature allows you to combine multiple readable streams into a single stream. The data from each stream is read in the order the streams were provided. In this example, the contents of 'file1.txt', 'file2.txt', and 'file3.txt' are read sequentially and output to the console.
const OrderedReadStreams = require('ordered-read-streams');
const fs = require('fs');
const stream1 = fs.createReadStream('file1.txt');
const stream2 = fs.createReadStream('file2.txt');
const stream3 = fs.createReadStream('file3.txt');
const combinedStream = new OrderedReadStreams([stream1, stream2, stream3]);
combinedStream.on('data', (chunk) => {
console.log(chunk.toString());
});
combinedStream.on('end', () => {
console.log('All streams have been read in order.');
});
The multistream package also allows you to combine multiple streams into a single stream. However, unlike ordered-read-streams, multistream provides more flexibility by allowing you to dynamically add streams during the reading process. This can be useful if the streams to be combined are not known upfront.
The merge-stream package allows you to merge multiple streams into one. Unlike ordered-read-streams, merge-stream does not guarantee the order of the streams. It is useful when you need to process multiple streams concurrently and do not require the data to be in a specific order.
The stream-combiner2 package allows you to combine multiple streams into a pipeline. While it does not specifically focus on maintaining the order of streams, it is useful for creating complex stream processing pipelines where the output of one stream is the input to another.
Combines array of streams into one read stream in strict order.
npm install ordered-read-streams
ordered-read-streams
handles all data/errors from input streams in parallel, but emits data/errors in strict order in which streams are passed to constructor. This is objectMode = true
stream.
var through = require('through2');
var Ordered = require('ordered-read-streams');
var s1 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 200)
});
var s2 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 30)
});
var s3 = through.obj(function (data, enc, next) {
var self = this;
setTimeout(function () {
self.push(data);
next();
}, 100)
});
var streams = new Ordered([s1, s2, s3]);
streams.on('data', function (data) {
console.log(data);
})
s1.write('stream 1');
s1.end();
s2.write('stream 2');
s2.end();
s3.write('stream 3');
s3.end();
Ouput will be:
stream 1
stream 2
stream 3
MIT
FAQs
Combines array of streams into one Readable stream in strict order.
The npm package ordered-read-streams receives a total of 983,495 weekly downloads. As such, ordered-read-streams popularity was classified as popular.
We found that ordered-read-streams demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.