Module

std/node/stream.ts>Readable#unpipe

Deno standard library
Go to Latest
method Readable.prototype.unpipe
import { Readable } from "https://dotland.deno.dev/std@0.177.0/node/stream.ts";

The readable.unpipe() method detaches a Writable stream previously attached using the {@link pipe} method.

If the destination is not specified, then all pipes are detached.

If the destination is specified, but no pipe is set up for it, then the method does nothing.

const fs = require('fs');
const readable = getReadableStreamSomehow();
const writable = fs.createWriteStream('file.txt');
// All the data from readable goes into 'file.txt',
// but only for the first second.
readable.pipe(writable);
setTimeout(() => {
  console.log('Stop writing to file.txt.');
  readable.unpipe(writable);
  console.log('Manually close the file stream.');
  writable.end();
}, 1000);

Parameters

optional
destination: WritableStream

Optional specific stream to unpipe