First we'll require through2:
const through = require('through2')
Next we'll use it to create a stream that uppercases incoming data:
const upper = through((chunk, enc, cb) => {
cb(null, chunk.toString().toUpperCase())
})
Finally, we'll create a pipeline from the terminal's STDIN through our upper stream to the terminal's STDOUT:
process.stdin.pipe(upper).pipe(process.stdout)
Now if we start our program:
$ node index.js
Each line we type into the terminal will be uppercased, as demonstrated in the following image: