import { BufferEncoding, EventMap, EventEmitter } from './runtime' interface StreamCallback { (err: Error | null): void } type Pipeline = [src: Readable, ...transforms: Duplex[], dest: S] declare function pipeline(streams: Pipeline, cb?: StreamCallback): S declare function pipeline(...args: Pipeline): S declare function pipeline(...args: [...Pipeline, cb: StreamCallback]): S declare function pipelinePromise(...args: Pipeline): Promise declare function isStream(stream: Stream): stream is Stream declare function isStreamx(stream: Stream): boolean declare function isEnding(stream: Stream): boolean declare function isEnded(stream: Stream): boolean declare function isFinishing(stream: Stream): boolean declare function isFinished(stream: Stream): boolean declare function isDisturbed(stream: Stream): boolean interface GetStreamErrorOptions { all?: boolean } declare function getStreamError(stream: Stream, opts?: GetStreamErrorOptions): Error | null interface StreamEvents extends EventMap { close: [] error: [err: Error] } interface StreamOptions { byteLength?(data: unknown): number destroy?(this: S, cb: StreamCallback): void eagerOpen?: boolean highWaterMark?: number map?(data: unknown): unknown open?(this: S, cb: StreamCallback): void predestroy?(this: S): void signal?: AbortSignal } interface Stream extends EventEmitter { _open(cb: StreamCallback): void _predestroy(): void _destroy(cb: StreamCallback): void readonly readable: boolean readonly writable: boolean readonly destroyed: boolean readonly destroying: boolean destroy(err?: Error | null): void } declare class Stream { constructor(opts?: StreamOptions) } interface WritableEvents extends StreamEvents { drain: [] finish: [] pipe: [src: Readable] } interface WritableOptions extends StreamOptions { byteLengthWritable?(data: unknown): number final?(this: S, cb: StreamCallback): void mapWritable?(data: unknown): unknown write?(this: S, data: unknown, cb: StreamCallback): void writev?(this: S, batch: unknown[], cb: StreamCallback): void } interface Writable extends Stream { _write(data: unknown, cb: StreamCallback): void _writev(batch: unknown[], cb: StreamCallback): void _final(cb: StreamCallback): void write(data: unknown): unknown end(data: unknown): this cork(): void uncork(): void } declare class Writable extends Stream { constructor(opts?: WritableOptions) static isBackpressured(ws: Writable): boolean static drained(ws: Writable): Promise } interface ReadableEvents extends StreamEvents { data: [data: unknown] end: [] piping: [dest: Writable] readable: [] } interface ReadableOptions extends StreamOptions { byteLengthReadable?(data: unknown): number encoding?: BufferEncoding mapReadable?(data: unknown): unknown read?(this: S, cb: StreamCallback): void } interface Readable extends Stream, AsyncIterable { _read(cb: StreamCallback): void push(data: unknown | null): boolean unshift(data: unknown | null): void read(): unknown | null resume(): this pause(): this pipe(dest: S, cb?: StreamCallback): S setEncoding(encoding: BufferEncoding): this } declare class Readable extends Stream { constructor(opts?: ReadableOptions) static deferred(fn: () => Promise, opts?: TransformOptions): Transform static from(data: unknown | unknown[] | AsyncIterable, opts?: ReadableOptions): Readable static isBackpressured(rs: Readable): boolean static isPaused(rs: Readable): boolean } interface DuplexEvents extends ReadableEvents, WritableEvents {} interface DuplexOptions extends ReadableOptions, WritableOptions {} interface Duplex extends Readable, Writable {} declare class Duplex extends Stream { constructor(opts?: DuplexOptions) } interface TransformCallback { (err: Error | null, mappedData: unknown): void } interface TransformEvents extends DuplexEvents {} interface TransformOptions extends DuplexOptions { flush?(this: S, cb: StreamCallback): void transform?(this: S, data: unknown, cb: TransformCallback): void } interface Transform extends Duplex { _flush(cb: StreamCallback): void _transform(Data: unknown, cb: TransformCallback): void } declare class Transform extends Duplex { constructor(opts?: TransformOptions) } export { type Pipeline, pipeline, pipelinePromise, isStream, isStreamx, isEnding, isEnded, isFinishing, isFinished, isDisturbed, type GetStreamErrorOptions, getStreamError, type StreamEvents, type StreamOptions, Stream, type WritableEvents, type WritableOptions, Writable, type ReadableEvents, type ReadableOptions, Readable, type DuplexEvents, type DuplexOptions, Duplex, type TransformEvents, type TransformOptions, Transform, Transform as PassThrough }