在变换stream中使用Node.js readline

我们有一个巨大的文本文件,我们想要使用stream逐行操作。

有没有在转换stream中使用Node.js readline模块的方法? 比如让整个文本用大写字母(逐行处理)?

event-stream可能更适合。 它可以分割线上的input,并以各种方式变换这些线(+更多)。

例如,大写从标准input读取的所有内容:

 const es = require('event-stream'); process.stdin .pipe(es.split()) // split lines .pipe(es.mapSync(data => data.toUpperCase())) // uppercase the line .pipe(es.join('\n')) // add a newline again .pipe(process.stdout); // write to stdout