/**
 * Native Stream Implementation - Browser
 *
 * Uses Web Streams API (ReadableStream, WritableStream, TransformStream)
 * for true native streaming in browsers.
 *
 * Supported browsers:
 * - Chrome >= 89
 * - Firefox >= 102
 * - Safari >= 14.1
 * - Edge >= 89
 */
import type { TransformStreamOptions, ReadableStreamOptions, WritableStreamOptions, DuplexStreamOptions, PullStreamOptions, BufferedStreamOptions, ICollector, IDuplex, IEventEmitter, IPassThrough, IReadable, ITransform, IWritable, PipelineStreamLike, ReadableLike, WritableLike } from "@stream/types";
import type { Writable as NodeWritable } from "stream";
import { EventEmitter } from "@stream/event-emitter";
import { PullStream } from "@stream/pull-stream";
import { BufferedStream, BufferChunk, StringChunk } from "@stream/buffered-stream";
/**
 * A wrapper around Web ReadableStream that provides Node.js-like API
 */
export declare class Readable<T = Uint8Array> extends EventEmitter {
    private _stream;
    private _reader;
    private _buffer;
    private _bufferIndex;
    private _unshiftBuffer;
    private _bufferSize;
    private _reading;
    private _ended;
    private _endEmitted;
    private _destroyed;
    private _errored;
    private _closed;
    private _paused;
    private _flowing;
    private _pipeTo;
    private _pipeListeners;
    private _encoding;
    private _decoder;
    private _didRead;
    private _aborted;
    private _pushMode;
    private _webStreamMode;
    readonly objectMode: boolean;
    readonly readableHighWaterMark: number;
    readonly autoDestroy: boolean;
    readonly emitClose: boolean;
    private _read?;
    constructor(options?: ReadableStreamOptions & {
        stream?: ReadableStream<T>;
        autoDestroy?: boolean;
        emitClose?: boolean;
        read?: (this: Readable<T>, size?: number) => void;
    });
    /**
     * Create a Readable from an iterable (static factory method)
     */
    static from<T>(iterable: Iterable<T> | AsyncIterable<T>, options?: ReadableStreamOptions): Readable<T>;
    /**
     * Check if a stream has been disturbed (read from)
     */
    static isDisturbed(stream: Readable<any>): boolean;
    /**
     * Convert a Web ReadableStream to Node.js Readable
     */
    static fromWeb<T>(webStream: ReadableStream<T>, options?: ReadableStreamOptions): Readable<T>;
    /**
     * Convert a Node.js Readable to Web ReadableStream
     */
    static toWeb<T>(nodeStream: Readable<T>): ReadableStream<T>;
    /**
     * Push data to the stream (when using controllable stream)
     */
    push(chunk: T | null): boolean;
    private _emitEndOnce;
    /**
     * Put a chunk back at the front of the buffer
     * Note: unshift is allowed even after end, as it's used to put back already read data
     */
    unshift(chunk: T): void;
    /**
     * Read data from the stream
     */
    read(size?: number): T | null;
    private _bufferedLength;
    private _bufferPeek;
    private _bufferShift;
    private _bufferUnshift;
    private _getChunkSize;
    /**
     * Set encoding for string output
     */
    setEncoding(encoding: string): this;
    private _applyEncoding;
    /**
     * Wrap an old-style stream
     */
    wrap(stream: any): this;
    /**
     * Pause the stream
     */
    pause(): this;
    /**
     * Resume the stream
     */
    resume(): this;
    /**
     * Override on() to automatically resume when 'data' listener is added
     * This matches Node.js behavior where adding a 'data' listener puts
     * the stream into flowing mode.
     */
    on(event: string | symbol, listener: (...args: any[]) => void): this;
    /**
     * Check if paused
     */
    isPaused(): boolean;
    /**
     * Pipe to a writable stream, transform stream, or duplex stream
     */
    pipe<W extends Writable<T> | Transform<T, any> | Duplex<any, T>>(destination: W): W;
    /**
     * Unpipe from destination
     */
    unpipe(destination?: WritableLike): this;
    /**
     * Destroy the stream
     */
    destroy(error?: Error): this;
    /**
     * Get the underlying Web ReadableStream
     */
    get webStream(): ReadableStream<T>;
    get readable(): boolean;
    get readableEnded(): boolean;
    get readableLength(): number;
    /** Whether the stream has been destroyed */
    get destroyed(): boolean;
    /** The error that destroyed the stream, or null */
    get errored(): Error | null;
    /** Whether the stream has been closed */
    get closed(): boolean;
    /** Whether the stream is in flowing mode */
    get readableFlowing(): boolean | null;
    /** Whether the stream was aborted */
    get readableAborted(): boolean;
    /** Whether read() has ever been called */
    get readableDidRead(): boolean;
    /** Current encoding or null */
    get readableEncoding(): string | null;
    /** Returns array of objects containing info about buffered data */
    get readableObjectMode(): boolean;
    /**
     * Get the internal buffer state (for debugging)
     * Returns array of objects with length and chunk info
     */
    get readableBuffer(): {
        length: number;
        head: T | null;
    };
    private _startReading;
    /**
     * Async iterator support
     * Uses a unified event-queue iterator with simple backpressure.
     * This matches Node's behavior more closely (iterator drives flowing mode).
     */
    [Symbol.asyncIterator](): AsyncIterableIterator<T>;
    /**
     * Explicit iterator method (same as Symbol.asyncIterator)
     */
    iterator(options?: {
        destroyOnReturn?: boolean;
    }): AsyncIterableIterator<T>;
    /**
     * Map each chunk through an async function
     */
    map<R>(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => R | Promise<R>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): AsyncGenerator<R, void, unknown>;
    /**
     * Filter chunks through an async predicate
     */
    filter(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => boolean | Promise<boolean>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): AsyncGenerator<T, void, unknown>;
    /**
     * FlatMap each chunk
     */
    flatMap<R>(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => AsyncIterable<R> | Iterable<R>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): AsyncGenerator<R, void, unknown>;
    /**
     * Take the first n chunks
     */
    take(limit: number, options?: {
        signal?: AbortSignal;
    }): AsyncGenerator<T, void, unknown>;
    /**
     * Drop the first n chunks
     */
    drop(limit: number, options?: {
        signal?: AbortSignal;
    }): AsyncGenerator<T, void, unknown>;
    /**
     * Reduce all chunks to a single value
     */
    reduce(fn: (previous: T, data: T, options?: {
        signal?: AbortSignal;
    }) => T | Promise<T>, initial?: T, options?: {
        signal?: AbortSignal;
    }): Promise<T>;
    reduce<R>(fn: (previous: R, data: T, options?: {
        signal?: AbortSignal;
    }) => R | Promise<R>, initial: R, options?: {
        signal?: AbortSignal;
    }): Promise<R>;
    /**
     * Check if every chunk passes a predicate
     */
    every(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => boolean | Promise<boolean>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): Promise<boolean>;
    /**
     * Check if some chunk passes a predicate
     */
    some(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => boolean | Promise<boolean>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): Promise<boolean>;
    /**
     * Find first chunk that passes predicate
     */
    find(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => boolean | Promise<boolean>, options?: {
        signal?: AbortSignal;
    }): Promise<T | undefined>;
    /**
     * Execute function for each chunk (like forEach)
     */
    forEach(fn: (data: T, options?: {
        signal?: AbortSignal;
    }) => void | Promise<void>, options?: {
        concurrency?: number;
        signal?: AbortSignal;
    }): Promise<void>;
    /**
     * Collect all chunks into an array
     */
    toArray(options?: {
        signal?: AbortSignal;
    }): Promise<T[]>;
    /**
     * Yield [index, value] pairs
     */
    asIndexedPairs(options?: {
        signal?: AbortSignal;
    }): AsyncGenerator<[number, T], void, unknown>;
    /**
     * Compose this stream with another iterable/stream
     */
    compose<R>(stream: (source: AsyncIterable<T>) => AsyncIterable<R>): Readable<R>;
    compose<R>(stream: Duplex<R, T>): Duplex<R, T>;
}
/**
 * A wrapper around Web WritableStream that provides Node.js-like API
 */
export declare class Writable<T = Uint8Array> extends EventEmitter {
    private _stream;
    private _writer;
    private _ended;
    private _finished;
    private _destroyed;
    private _errored;
    private _closed;
    private _pendingWrites;
    private _writableLength;
    private _needDrain;
    private _corked;
    private _corkedChunks;
    private _defaultEncoding;
    private _aborted;
    private _ownsStream;
    private _writeFunc?;
    private _finalFunc?;
    readonly objectMode: boolean;
    readonly writableHighWaterMark: number;
    readonly autoDestroy: boolean;
    readonly emitClose: boolean;
    constructor(options?: WritableStreamOptions & {
        stream?: WritableStream<T>;
        autoDestroy?: boolean;
        emitClose?: boolean;
        defaultEncoding?: string;
        write?: (this: Writable<T>, chunk: T, encoding: string, callback: (error?: Error | null) => void) => void;
        final?: (this: Writable<T>, callback: (error?: Error | null) => void) => void;
    });
    /**
     * Set default encoding for string writes
     */
    setDefaultEncoding(encoding: string): this;
    /**
     * Buffer writes until uncork() is called
     */
    cork(): void;
    /**
     * Flush buffered writes from cork()
     */
    uncork(): void;
    /**
     * Write data to the stream
     */
    write(chunk: T, callback?: (error?: Error | null) => void): boolean;
    write(chunk: T, encoding?: string, callback?: (error?: Error | null) => void): boolean;
    private _doWrite;
    private _getChunkSize;
    /**
     * End the stream
     */
    end(callback?: () => void): this;
    end(chunk: T, callback?: () => void): this;
    end(chunk: T, encoding?: string, callback?: () => void): this;
    /**
     * Destroy the stream
     */
    destroy(error?: Error): this;
    /**
     * Get the underlying Web WritableStream
     */
    get webStream(): WritableStream<T>;
    get writable(): boolean;
    get writableEnded(): boolean;
    get writableFinished(): boolean;
    get writableLength(): number;
    /** Whether the stream has been destroyed */
    get destroyed(): boolean;
    /** The error that destroyed the stream, or null */
    get errored(): Error | null;
    /** Whether the stream has been closed */
    get closed(): boolean;
    /** Whether the stream needs drain (writableLength exceeds high water mark) */
    get writableNeedDrain(): boolean;
    /** How many times cork() has been called without uncork() */
    get writableCorked(): number;
    /** Whether the stream was aborted */
    get writableAborted(): boolean;
    /** Whether the stream is in object mode */
    get writableObjectMode(): boolean;
    /** Get default encoding */
    get defaultEncoding(): string;
    /**
     * Get the internal buffer state (for debugging)
     * Returns array of objects with length and chunk info
     */
    get writableBuffer(): {
        length: number;
        head: T | null;
    };
    /**
     * Write multiple chunks at once (batch write).
     * Override in subclass to implement custom batch write logic.
     */
    _writev(chunks: Array<{
        chunk: T;
        encoding?: string;
    }>, callback: (error?: Error | null) => void): void;
    /**
     * Batch write multiple chunks
     */
    writev(chunks: Array<{
        chunk: T;
        encoding?: string;
    }>, callback?: (error?: Error | null) => void): boolean;
    private _getWriter;
    /**
     * Convert a Web WritableStream to Node.js Writable
     */
    static fromWeb<T>(webStream: WritableStream<T>, options?: WritableStreamOptions): Writable<T>;
    /**
     * Convert a Node.js Writable to Web WritableStream
     */
    static toWeb<T>(nodeStream: Writable<T>): WritableStream<T>;
}
/**
 * Normalize a user-provided writable into this module's Writable.
 * Keeps Web/Node branching at the stream-module boundary.
 */
export declare function normalizeWritable<T = Uint8Array>(stream: WritableLike | WritableStream<T> | NodeWritable): WritableLike;
/**
 * A wrapper around Web TransformStream that provides Node.js-like API
 */
export declare class Transform<TInput = Uint8Array, TOutput = Uint8Array> extends EventEmitter {
    /** @internal - for pipe() support */
    readonly _readable: Readable<TOutput>;
    /** @internal - for pipe() support */
    readonly _writable: Writable<TInput>;
    readonly objectMode: boolean;
    private _destroyed;
    private _ended;
    private _errored;
    private _dataForwardingSetup;
    private _endTimer;
    private _webStream;
    private _sideForwardingCleanup;
    private _transformImpl;
    private _flushImpl;
    /**
     * Push data to the readable side (Node.js compatibility).
     * Intended to be called from within transform/flush.
     */
    push(chunk: TOutput | null): boolean;
    constructor(options?: TransformStreamOptions & {
        transform?: ((chunk: TInput) => TOutput | Promise<TOutput>) | ((this: Transform<TInput, TOutput>, chunk: TInput, encoding: string, callback: (error?: Error | null, data?: TOutput) => void) => void);
        flush?: (() => TOutput | void | Promise<TOutput | void>) | ((this: Transform<TInput, TOutput>, callback: (error?: Error | null, data?: TOutput) => void) => void);
    });
    private _setupSideForwarding;
    private _scheduleEnd;
    private _emitErrorOnce;
    private _hasSubclassTransform;
    private _hasSubclassFlush;
    private _runTransform;
    private _runFlush;
    /**
     * Override on() to lazily forward readable 'data' events.
     * Avoids starting flowing mode unless requested.
     */
    on(event: string | symbol, listener: (...args: any[]) => void): this;
    /**
     * Write to the writable side
     */
    write(chunk: TInput, callback?: (error?: Error | null) => void): boolean;
    write(chunk: TInput, encoding?: string, callback?: (error?: Error | null) => void): boolean;
    /**
     * End the transform stream
     * Delays closing to allow writes during data events to complete
     */
    end(callback?: () => void): this;
    end(chunk: TInput, callback?: () => void): this;
    end(chunk: TInput, encoding?: string, callback?: () => void): this;
    /**
     * Read from the transform stream
     */
    read(size?: number): TOutput | null;
    /**
     * Pipe readable side to destination
     */
    pipe<W extends Writable<TOutput> | Transform<TOutput, any> | Duplex<any, TOutput>>(destination: W): W;
    /**
     * Unpipe from destination
     */
    unpipe(destination?: any): this;
    /**
     * Check if paused
     */
    isPaused(): boolean;
    /**
     * Resume reading from the readable side
     */
    resume(): this;
    /**
     * Pause reading from the readable side
     */
    pause(): this;
    /**
     * Destroy the stream
     */
    destroy(error?: Error): void;
    /**
     * Get the underlying Web TransformStream
     */
    get webStream(): TransformStream<TInput, TOutput>;
    get readable(): boolean;
    get writable(): boolean;
    get readableEnded(): boolean;
    get writableEnded(): boolean;
    get writableFinished(): boolean;
    get readableLength(): number;
    get writableLength(): number;
    get readableHighWaterMark(): number;
    get writableHighWaterMark(): number;
    get readableObjectMode(): boolean;
    get readableFlowing(): boolean | null;
    get destroyed(): boolean;
    /**
     * Async iterator support
     */
    [Symbol.asyncIterator](): AsyncIterableIterator<TOutput>;
    /**
     * Convert a Web TransformStream to Node.js Transform
     */
    static fromWeb<TIn = Uint8Array, TOut = Uint8Array>(webStream: TransformStream<TIn, TOut>, options?: TransformStreamOptions): Transform<TIn, TOut>;
    /**
     * Convert a Node.js Transform to Web TransformStream
     */
    static toWeb<TIn = Uint8Array, TOut = Uint8Array>(nodeStream: Transform<TIn, TOut>): TransformStream<TIn, TOut>;
    /**
     * Base transform method - can be overridden by subclasses.
     * Default behavior: pass through chunk unchanged.
     */
    _transform(chunk: TInput, encoding: string, callback: (error?: Error | null, data?: TOutput) => void): void;
    /**
     * Base flush method - can be overridden by subclasses.
     * Called when the stream ends to allow final processing.
     */
    _flush(callback: (error?: Error | null, data?: TOutput) => void): void;
}
/**
 * A duplex stream that combines readable and writable
 */
export declare class Duplex<TRead = Uint8Array, TWrite = Uint8Array> extends EventEmitter {
    /** @internal - for pipe() support */
    readonly _readable: Readable<TRead>;
    /** @internal - for pipe() support */
    readonly _writable: Writable<TWrite>;
    readonly allowHalfOpen: boolean;
    readonly readableObjectMode: boolean;
    readonly writableObjectMode: boolean;
    /**
     * Create a Duplex stream from various sources
     */
    static from<R = Uint8Array, W = Uint8Array>(source: Duplex<R, W> | Readable<R> | Writable<W> | AsyncIterable<R> | Iterable<R> | {
        readable?: Readable<R>;
        writable?: Writable<W>;
    }): Duplex<R, W>;
    /**
     * Create a Duplex from a Web ReadableWritablePair
     */
    static fromWeb<R = Uint8Array, W = Uint8Array>(pair: {
        readable: ReadableStream<R>;
        writable: WritableStream<W>;
    }, options?: DuplexStreamOptions): Duplex<R, W>;
    /**
     * Convert a Node.js Duplex to Web ReadableWritablePair
     */
    static toWeb<R = Uint8Array, W = Uint8Array>(duplex: Duplex<R, W>): {
        readable: ReadableStream<R>;
        writable: WritableStream<W>;
    };
    private _dataForwardingSetup;
    private _sideForwardingCleanup;
    constructor(options?: DuplexStreamOptions & {
        allowHalfOpen?: boolean;
        objectMode?: boolean;
        read?: (this: Duplex<TRead, TWrite>, size?: number) => void;
        write?: (this: Duplex<TRead, TWrite>, chunk: TWrite, encoding: string, callback: (error?: Error | null) => void) => void;
        final?: (this: Duplex<TRead, TWrite>, callback: (error?: Error | null) => void) => void;
    });
    private _setupSideForwarding;
    /**
     * Override on() to set up data forwarding lazily
     */
    on(event: string | symbol, listener: (...args: any[]) => void): this;
    /**
     * Push data to readable side
     */
    push(chunk: TRead | null): boolean;
    /**
     * Put a chunk back at the front of the buffer (readable side)
     */
    unshift(chunk: TRead): void;
    /**
     * Read from readable side
     */
    read(size?: number): TRead | null;
    /**
     * Write to writable side
     */
    write(chunk: TWrite, callback?: (error?: Error | null) => void): boolean;
    write(chunk: TWrite, encoding?: string, callback?: (error?: Error | null) => void): boolean;
    /**
     * End writable side
     */
    end(callback?: () => void): this;
    end(chunk: TWrite, callback?: () => void): this;
    end(chunk: TWrite, encoding?: string, callback?: () => void): this;
    /**
     * Cork the writable side
     */
    cork(): void;
    /**
     * Uncork the writable side
     */
    uncork(): void;
    /**
     * Set encoding for readable side
     */
    setEncoding(encoding: string): this;
    /**
     * Set default encoding for writable side
     */
    setDefaultEncoding(encoding: string): this;
    /**
     * Pipe readable side to destination
     */
    pipe<W extends Writable<TRead> | Transform<TRead, any>>(destination: W): W;
    /**
     * Unpipe from destination
     */
    unpipe(destination?: Writable<TRead>): this;
    /**
     * Pause the readable side
     */
    pause(): this;
    /**
     * Resume the readable side
     */
    resume(): this;
    /**
     * Check if paused
     */
    isPaused(): boolean;
    /**
     * Destroy both sides
     */
    destroy(error?: Error): this;
    get readable(): boolean;
    get writable(): boolean;
    get readableEnded(): boolean;
    get writableEnded(): boolean;
    get writableFinished(): boolean;
    get readableLength(): number;
    get writableLength(): number;
    get readableHighWaterMark(): number;
    get writableHighWaterMark(): number;
    get destroyed(): boolean;
    get writableCorked(): number;
    get writableNeedDrain(): boolean;
    /**
     * Async iterator support
     */
    [Symbol.asyncIterator](): AsyncIterableIterator<TRead>;
}
/**
 * A passthrough stream that passes data through unchanged
 */
export declare class PassThrough<T = Uint8Array> extends Transform<T, T> {
    constructor(options?: TransformStreamOptions);
}
/**
 * A writable stream that collects all chunks
 */
export declare class Collector<T = Uint8Array> extends Writable<T> {
    chunks: T[];
    constructor(options?: WritableStreamOptions);
    write(chunk: T, callback?: (error?: Error | null) => void): boolean;
    write(chunk: T, encoding?: string, callback?: (error?: Error | null) => void): boolean;
    /**
     * Get all collected data as a single Uint8Array (for binary mode)
     */
    toUint8Array(): Uint8Array;
    /**
     * Get all collected data as a string
     */
    toString(): string;
    get isFinished(): boolean;
}
export { PullStream, BufferedStream, StringChunk, BufferChunk };
/**
 * Create a readable stream with custom read implementation
 */
export declare function createReadable<T = Uint8Array>(options?: ReadableStreamOptions & {
    read?: (size: number) => void;
    destroy?: (error: Error | null, callback: (error: Error | null) => void) => void;
}): IReadable<T>;
/**
 * Create a readable stream from an async iterable
 */
export declare function createReadableFromAsyncIterable<T>(iterable: AsyncIterable<T>, options?: ReadableStreamOptions): IReadable<T>;
/**
 * Create a readable stream from an array
 */
export declare function createReadableFromArray<T>(data: T[], options?: ReadableStreamOptions): IReadable<T>;
/**
 * Create a writable stream with custom write implementation
 */
export declare function createWritable<T = Uint8Array>(options?: WritableStreamOptions & {
    write?: (chunk: T, encoding: string, callback: (error?: Error | null) => void) => void;
    final?: (callback: (error?: Error | null) => void) => void;
    destroy?: (error: Error | null, callback: (error: Error | null) => void) => void;
}): IWritable<T>;
/**
 * Create a transform stream from a transform function
 */
export declare function createTransform<TInput = Uint8Array, TOutput = Uint8Array>(transformFn: (chunk: TInput, encoding?: string) => TOutput | Promise<TOutput>, options?: TransformStreamOptions & {
    flush?: () => TOutput | Promise<TOutput> | void;
}): ITransform<TInput, TOutput>;
/**
 * Create a collector stream
 */
export declare function createCollector<T = Uint8Array>(options?: WritableStreamOptions): ICollector<T>;
/**
 * Create a passthrough stream
 */
export declare function createPassThrough<T = any>(options?: TransformStreamOptions): IPassThrough<T>;
/**
 * Create a pull stream
 */
export declare function createPullStream(options?: PullStreamOptions): PullStream;
/**
 * Create a buffered stream
 */
export declare function createBufferedStream(options?: BufferedStreamOptions): BufferedStream;
export interface PipelineOptions {
    /** AbortSignal to cancel the pipeline */
    signal?: AbortSignal;
    /** Whether to call end() on the destination when source ends */
    end?: boolean;
}
type PipelineStream = PipelineStreamLike;
type PipelineCallback = (err?: Error | null) => void;
/**
 * Pipeline streams together with proper error handling and cleanup.
 * Supports both callback and promise-based usage like Node.js.
 *
 * @example
 * // Promise usage
 * await pipeline(source, transform, destination);
 *
 * @example
 * // With options
 * await pipeline(source, transform, destination, { signal: controller.signal });
 *
 * @example
 * // Callback usage
 * pipeline(source, transform, destination, (err) => {
 *   if (err) console.error('Pipeline failed', err);
 * });
 */
export declare function pipeline(...args: [...PipelineStream[], PipelineOptions | PipelineCallback] | PipelineStream[]): Promise<void>;
export interface FinishedOptions {
    /** Check for readable stream completion */
    readable?: boolean;
    /** Check for writable stream completion */
    writable?: boolean;
    /** Resolve on error instead of reject */
    error?: boolean;
    /** AbortSignal to cancel waiting */
    signal?: AbortSignal;
}
/**
 * Wait for a stream to finish, close, or error.
 * Node.js compatible with support for options and callbacks.
 *
 * @example
 * // Promise usage
 * await finished(stream);
 *
 * @example
 * // With options
 * await finished(stream, { readable: false }); // Only wait for writable side
 *
 * @example
 * // Callback usage
 * finished(stream, (err) => {
 *   if (err) console.error('Stream error', err);
 * });
 */
export declare function finished(stream: PipelineStream, optionsOrCallback?: FinishedOptions | ((err?: Error | null) => void), callback?: (err?: Error | null) => void): Promise<void>;
/**
 * Convert a stream to a promise that resolves when finished
 */
export declare function streamToPromise(stream: PipelineStream): Promise<void>;
/**
 * Collect all data from a readable stream into a Uint8Array
 * (Browser equivalent of Node.js streamToBuffer)
 */
export declare function streamToUint8Array(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>): Promise<Uint8Array>;
/**
 * Alias for streamToUint8Array (Node.js compatibility)
 */
export declare const streamToBuffer: typeof streamToUint8Array;
/**
 * Collect all data from a readable stream into a string
 */
export declare function streamToString(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>, encoding?: string): Promise<string>;
/**
 * Drain a stream (consume all data without processing)
 */
export declare function drainStream(stream: AsyncIterable<unknown> | ReadableStream<unknown>): Promise<void>;
/**
 * Copy from a readable stream to a writable stream
 */
export declare function copyStream(source: PipelineStreamLike, destination: PipelineStreamLike): Promise<void>;
/**
 * Check if an object is a transform stream
 */
export declare function isTransform(obj: unknown): obj is ITransform<any, any>;
/**
 * Check if an object is a duplex stream
 * Note: In Node.js, Transform extends Duplex, so Transform is also a Duplex
 */
export declare function isDuplex(obj: unknown): obj is IDuplex<any, any>;
/**
 * Check if an object is any kind of stream
 */
export declare function isStream(obj: unknown): obj is ReadableLike | WritableLike;
/**
 * Add abort signal handling to any stream
 */
export declare function addAbortSignal<T extends (ReadableLike | WritableLike) & {
    destroy(error?: Error): any;
}>(signal: AbortSignal, stream: T): T;
/**
 * Create a duplex stream from a pair of readable and writable streams
 */
export declare function createDuplex<TRead = Uint8Array, TWrite = Uint8Array>(options?: DuplexStreamOptions & {
    readable?: unknown;
    writable?: unknown;
    allowHalfOpen?: boolean;
    objectMode?: boolean;
    read?: (this: any, size: number) => void;
    write?: (this: any, chunk: TWrite, encoding: string, callback: (error?: Error | null) => void) => void;
    final?: (this: any, callback: (error?: Error | null) => void) => void;
    destroy?: (this: any, error: Error | null, callback: (error: Error | null) => void) => void;
}): IDuplex<TRead, TWrite>;
/**
 * Create a readable stream from a generator function
 */
export declare function createReadableFromGenerator<T>(generator: () => AsyncGenerator<T, void, unknown>, options?: ReadableStreamOptions): IReadable<T>;
/**
 * Create a readable stream from a Promise
 */
export declare function createReadableFromPromise<T>(promise: Promise<T>, options?: ReadableStreamOptions): IReadable<T>;
/**
 * Compose multiple transform streams into one
 * Data flows through each transform in sequence
 */
export declare function compose<T = any, R = any>(...transforms: Array<ITransform<any, any>>): Transform<T, R>;
/**
 * Wait for multiple streams to finish
 */
export declare function finishedAll(streams: ReadonlyArray<PipelineStreamLike>): Promise<void>;
/**
 * Create a readable stream that emits nothing and immediately ends
 */
export declare function createEmptyReadable<T = Uint8Array>(options?: ReadableStreamOptions): IReadable<T>;
/**
 * Create a writable stream that discards all data (like /dev/null)
 */
export declare function createNullWritable<T = any>(options?: WritableStreamOptions): IWritable<T>;
/**
 * Promisified version of once for events
 */
export declare function once(emitter: IEventEmitter, event: string, options?: {
    signal?: AbortSignal;
}): Promise<any[]>;
/**
 * Convert a callback-based stream operation to a promise
 */
export declare function promisify<T>(fn: (callback: (error?: Error | null, result?: T) => void) => void): Promise<T>;
/**
 * Get the default high water mark for streams
 */
export declare function getDefaultHighWaterMark(objectMode: boolean): number;
/**
 * Set the default high water mark for streams
 */
export declare function setDefaultHighWaterMark(objectMode: boolean, value: number): void;
/**
 * Check if a stream has been destroyed
 */
export declare function isDestroyed(stream: {
    destroyed?: boolean;
} | null | undefined): boolean;
/**
 * Check if a readable stream has been disturbed (read from)
 */
export declare function isDisturbed(stream: unknown): boolean;
/**
 * Check if a stream has an error
 */
export declare function isErrored(stream: {
    errored?: unknown;
} | null | undefined): boolean;
/**
 * Check if a stream is readable
 */
export declare function isReadable(stream: unknown): stream is ReadableLike;
/**
 * Check if a stream is writable
 */
export declare function isWritable(stream: unknown): stream is WritableLike;
/**
 * Create a pair of connected Duplex streams
 * Data written to one stream can be read from the other
 */
export declare function duplexPair<T = Uint8Array>(options?: DuplexStreamOptions): [Duplex<T, T>, Duplex<T, T>];
export declare const consumers: {
    /**
     * Consume entire stream as ArrayBuffer
     */
    arrayBuffer(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>): Promise<ArrayBuffer>;
    /**
     * Consume entire stream as Blob
     */
    blob(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>, options?: BlobPropertyBag): Promise<Blob>;
    /**
     * Consume entire stream as Buffer (Uint8Array in browser)
     */
    buffer(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>): Promise<Uint8Array>;
    /**
     * Consume entire stream as JSON
     */
    json(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>): Promise<any>;
    /**
     * Consume entire stream as text
     */
    text(stream: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>, encoding?: string): Promise<string>;
};
export declare const promises: {
    pipeline: typeof pipeline;
    finished: typeof finished;
};
