'pipe' 事件
src
<stream.Readable> 管道到此可写流的源流
当在可读流上调用 stream.pipe()
方法将此可写流添加到其目标集时,则触发 'pipe'
事件。
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);
src
<stream.Readable> source stream that is piping to this writable
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);