API · Consume

pipe()

Connect an Exstream to another pipeline or a platform writable using destination-native return semantics.

Signature

pipe<D extends NodeWritableLike<T>>(destination: D, options?: PipeOptions): D
pipe(destination: WritableStream<T>, options?: PipeOptions): Promise<WritableStream<T>>
pipe<U, C2 extends object>(
  destination: Exstream<U, C2> | Pipeline<T, U, C2>,
  options?: PipeOptions,
): Exstream<U, C2>

Example

source.pipe(nodeWritable) // returns nodeWritable immediately
await source.pipe(webWritable) // resolves with webWritable
const transformed = source.pipe(exstream.pipeline().map(normalize))

Parameters

destination may be a Node-style writable, Web WritableStream, Exstream, or reusable pipeline. For a Node destination, pipe() uses end (default true, except standard output); the other PipeOptions fields are not applied by this legacy-returning path. For a Web destination, end, signal, preventAbort, and preventClose have the same meanings as pipeTo(). Exstream and pipeline destinations ignore sink options and compose through through().

Return and completion

The return type depends on the destination. Node piping follows Node convention and returns the destination before completion. Web piping returns a promise resolving to the writable. Exstream and pipeline destinations are composition and return the connected output stream.

Both Node and Web transfers honor destination backpressure. Record errors are forwarded to the destination error channel. For one consistent Promise<void> that rejects on all unhandled failures, use pipeTo().

Forms

pipe() is an instance method; the standalone terminal equivalent is pipeTo():

stream.pipe(destination, options)

pipeTo(), through(), toNodeStream(), toWebReadable()