The `stream-concat` library provides a simple and efficient mechanism for concatenating multiple Node.js readable streams into a single output readable stream. Currently at version `2.0.0`, it maintains an active development status, though a specific release cadence isn't explicitly defined. A core differentiator is its ability to handle streams in two ways: either by accepting an array of pre-existing streams or, more efficiently, by using a user-supplied function that returns the next stream on demand. This 'on-the-fly' stream creation significantly reduces memory consumption and improves performance, particularly when dealing with large datasets or numerous files, by preventing all streams from being buffered simultaneously. It builds upon Node.js's `Transform` stream, leveraging its underlying options like `highWaterMark` and `objectMode` for fine-grained control over stream behavior.
npm install stream-concatVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to concatenate multiple files efficiently using a `nextStream` function. This approach defers opening new streams until they are needed, optimizing memory usage compared to providing an array of all streams upfront.
Upgrade your Node.js environment to version 12 or newer, or use an older `stream-concat` version if you are constrained to an older Node.js runtime.
Instead of providing an array of streams, pass a function to the `StreamConcat` constructor that returns the next stream (or a Promise resolving to a stream) only when it's needed. This allows the library to manage buffering sequentially.
Since `stream-concat` is a CommonJS package, you must use `const StreamConcat = require('stream-concat');` to import it correctly in both CJS and ESM environments (where ESM allows CJS `require`).No dependency data recorded yet.