Learning node.js. Trumpet works by piping a stream back to itself, apparently, so the processed data can then be output. This makes no sense to me, since it seems to be like c
I was confused too and i would express it again with my words:
tr.select('.loud').createStream()
creates a Duplex-Stream which is nothing else than a combined ReadStream
and WriteStream
This Stream recieves all matches in its ReadStream. If you write to the WriteStream, trumpet takes it as match-replace
This works for me in the same way:
// create trumpet stream
var tr = trumpet();
// create stream with selected elems
var trumpetSelector = tr.select('.loud');
var upperOut = trumpetSelector.createReadStream();
var upperIn = trumpetSelector.createWriteStream();
upperOut.pipe(new UpperCaseTransformer()).pipe(upperIn);
Please correct me if i'm wrong!