I found two different ways to pipe streams in node.js
Well known .pipe() method of a stream
https://nodejs.org/api/stream.html#stream_readable_pip
pipeline is the improved version of pipe it was added to stream module since Node.js v10
Also, pipeline takes any number of arguments and the last argument is a callback used to know when the pipeline ends or throws an error.
Usage pipe:
mySourceStream.pipe(myStream).pipe(anotherStream)
Usage pipeline:
mySourceStream.pipeline(myStream, anotherStream, err => {
if (err) {
console.log('There is an error')
} else {
else console.log('pipeline successful')
}
})