...

/

Merging Streams: Merging Text Files

Merging Streams: Merging Text Files

Learn how to merge streams using piping patterns.

We'll cover the following...

Merging is the opposite operation to forking and involves piping a set of Readable streams into a single Writable stream, as shown in the illustration given below.

Press + to interact
Merging streams
Merging streams

Merging multiple streams into one is, in general, a simple operation; however, we have to pay attention to the way we handle the end event because piping using the default options (according to which {end:true}) causes the destination stream to end as soon as one of the sources ends. This can often lead to an error because the other active sources continue to write to an already terminated stream.

The solution to ...