NodeSchool——stream-adventure

Learn to compose streaming interfaces with .pipe().

MEET PIPE

参数输入,标准stdout输出

var fs = require('fs');
fs.createReadStream(process.argv[2]).pipe(process.stdout);

INPUT OUTPUT

stdin输入,stdin输出
process.stdin.pipe(process.stdout)

TRANSFORM

Convert data from `process.stdin` to upper-case data on `process.stdout` using the `through2` module.

<span style="font-weight: normal;">var through = require('through2');
var stream = through(write, end);

function write (buffer, encoding, next) {
   this.push(buffer.toString().toUpperCase());
   next();
}

function end() {
  //
}
process.stdin.pipe(stream).pipe(process.stdout);</span>




你可能感兴趣的:(NodeSchool——stream-adventure)