How to compose transform Streams in node.js
Unfortunately, there is no built-in way to do that, but there is cool multipipe package. Use like this:
var multipipe = require('multipipe');
var parser = multipipe(iconv.decodeStream('win1252'), csv.parse(), buildObject());
I've been struggling with this issue (and some others!). I found highlandjs solved nearly all my problems. In this case their pipeline command did the trick:
var h = require('highland');
var parser = h.pipeline(iconv.decodeStream('win1252'), csv.parse(), buildObject());
As of 2022, and nodejs v16, there is a new compose
function in the stream module, that build a Duplex stream from a list of streams.
see : https://nodejs.org/api/stream.html#streamcomposestreams
works with .pipe()
and async syntax.