发布于 2016-09-13 02:46:03
event-stream可能是更好的选择。它可以将输入拆分成行,并以各种方式转换这些行(+更多)。
例如,要大写从stdin读取的所有内容:
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 stdouthttps://stackoverflow.com/questions/39456361
复制相似问题