事件:'pipe'
【Event: 'pipe'】
src<stream.Readable> 正在传输到此可写流的源流
当在可读流上调用 stream.pipe() 方法时,会触发 'pipe' 事件,将此可写流添加到其目标集合中。
【The 'pipe' event is emitted when the stream.pipe() method is called on
a readable stream, adding this writable to its set of destinations.】
const writer = getWritableStreamSomehow();
const reader = getReadableStreamSomehow();
writer.on('pipe', (src) => {
console.log('Something is piping into the writer.');
assert.equal(src, reader);
});
reader.pipe(writer);