• destination {stream.Writable} 要移除管道的可写流。
    • 返回: {this}

    readable.unpipe() 方法解绑之前使用 [stream.pipe()] 方法绑定的可写流。

    如果没有指定 destination, 则解绑所有管道.

    如果指定了 destination, 但它没有建立管道,则不起作用.

    1. const fs = require('fs');
    2. const readable = getReadableStreamSomehow();
    3. const writable = fs.createWriteStream('file.txt');
    4. // 可读流的所有数据开始传输到 'file.txt',但一秒后停止。
    5. readable.pipe(writable);
    6. setTimeout(() => {
    7. console.log('停止写入 file.txt');
    8. readable.unpipe(writable);
    9. console.log('手动关闭文件流');
    10. writable.end();
    11. }, 1000);