I am trying to deal with streams in node.js, read the stream-handbook and some kind of porridge remained in my head (I decided to go through stream-adventure and there is such a task:
It is necessary to read data from stdin and output to stdout in upperCase.
I did this:
process.stdin.on('readable', function(){ var buf = process.stdin.read(); if(buf){ process.stdout.write(buf.toString().toUpperCase()); } }) But I would like to do the same through the pipe. I tried to do through an additional readable stream, in which I already pushed the already enlarged letters, which I linked already with stdout. Something like that:
var stream = require('stream'); var red = new stream.Readable(); process.stdin.on('readable', function(){ var buf = process.stdin.read(); if(buf){ red.push(buf.toString().toUpperCase()); } }) red.pipe(process.stdout); But an error was thrown, which I do not even know how to catch ( 
(source: joxi.ru )
Please tell me how to do this through the pipe without using additional libraries. And I would be very grateful for the sequential scheme of triggering events when data is received in the readable stream.
Updated.