/** * Node.js Stream - Utilities * * Stream utility functions, type guards, consumers, and state inspection. */ import type { DuplexStreamOptions, IDuplex, ITransform, ReadableLike, WritableLike } from "../types.js"; import { pipeline, finished } from "./pipeline.js"; /** Convert a stream to a promise that resolves when finished */ export declare const streamToPromise: typeof finished; /** Copy from a readable stream to a writable stream */ export declare const copyStream: typeof pipeline; /** * Collect all data from a readable stream into a Uint8Array * (Node.js equivalent of browser streamToBuffer) */ export declare function streamToBuffer(stream: AsyncIterable | ReadableStream): Promise; /** * Collect all data from a readable stream into a Uint8Array */ export declare function streamToUint8Array(stream: AsyncIterable | ReadableStream): Promise; /** * Collect all data from a readable stream into a string */ export declare function streamToString(stream: AsyncIterable | ReadableStream, encoding?: string): Promise; /** * Drain a stream (consume all data without processing) */ export declare function drainStream(stream: AsyncIterable | ReadableStream): Promise; /** Add abort signal handling to any stream */ export declare const addAbortSignal: (signal: AbortSignal, stream: T) => T; /** * Check if an object is a readable stream that is still in a readable state. * Returns false for destroyed or ended/finished streams (matches Node.js behavior). */ export declare function isReadable(obj: unknown): obj is ReadableLike; /** * Check if an object is a writable stream that is still in a writable state. * Returns false for destroyed or ended/finished streams (matches Node.js behavior). */ export declare function isWritable(obj: unknown): obj is WritableLike; /** Check if an object is a transform stream */ export declare const isTransform: (obj: unknown) => obj is ITransform; /** Check if an object is a duplex stream */ export declare const isDuplex: (obj: unknown) => obj is IDuplex; /** Check if an object is any kind of stream */ export declare const isStream: (obj: unknown) => obj is ReadableLike | WritableLike; /** * Check if a readable stream has been disturbed (read from or cancelled). * Matches Node.js native: readableDidRead || readableAborted. */ export declare function isDisturbed(stream: unknown): boolean; /** * Create a pair of connected Duplex streams * Data written to one stream can be read from the other */ export declare function duplexPair(options?: DuplexStreamOptions): [IDuplex, IDuplex]; export declare const consumers: import("../common/consumers.js").StreamConsumers; export declare const promises: { pipeline: typeof pipeline; finished: typeof finished; };