事件:'unpipe'
¥Event: 'unpipe'
-
src<stream.Readable> unpiped 这个可写的源码流¥
src<stream.Readable> The source stream that unpiped this writable
当在 Readable 流上调用 stream.unpipe() 方法时,则会触发 'unpipe' 事件,从其目标集合中删除此 Writable。
¥The 'unpipe' event is emitted when the stream.unpipe() method is called
on a Readable stream, removing this Writable from its set of
destinations.
当 Readable 流管道进入它时,如果此 Writable 流触发错误,则这也会触发。
¥This is also emitted in case this Writable stream emits an error when a
Readable stream pipes into it.
const writer = getWritableStreamSomehow();
const reader = getReadableStreamSomehow();
writer.on('unpipe', (src) => {
console.log('Something has stopped piping into the writer.');
assert.equal(src, reader);
});
reader.pipe(writer);
reader.unpipe(writer);