/** * Node.js Stream - Factory Functions * * Stream creation helper functions for Node.js. */ import { BufferedStream, StringChunk, ByteChunk } from "../buffered-stream.js"; import { PullStream } from "../pull-stream.js"; import type { ReadableStreamOptions, WritableStreamOptions, TransformStreamOptions, DuplexStreamOptions, PullStreamOptions, BufferedStreamOptions, IReadable, IWritable, ITransform, IDuplex, IPassThrough } from "../types.js"; export { PullStream, BufferedStream, StringChunk, ByteChunk }; /** Create a pull stream */ export declare function createPullStream(options?: PullStreamOptions): PullStream; /** Create a buffered stream */ export declare function createBufferedStream(options?: BufferedStreamOptions): BufferedStream; /** * Create a readable stream from various sources */ 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(iterable: AsyncIterable, options?: ReadableStreamOptions): IReadable; /** * Create a readable stream from an array */ export declare function createReadableFromArray(data: T[], options?: ReadableStreamOptions): IReadable; /** * Create a writable stream */ export declare function createWritable(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; /** * Create a transform stream from a transform function */ export declare function createTransform(transformFn: (chunk: TInput, encoding?: string) => TOutput | Promise, options?: TransformStreamOptions & { flush?: () => TOutput | Promise | void; }): ITransform; /** * Create a duplex stream */ 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 passthrough stream */ export declare function createPassThrough<_T = any>(options?: TransformStreamOptions): IPassThrough<_T>; /** * Create a readable stream from a generator function */ export declare function createReadableFromGenerator(generator: () => AsyncGenerator, options?: ReadableStreamOptions): IReadable; /** * Create a readable stream from a Promise */ export declare function createReadableFromPromise(promise: Promise, options?: ReadableStreamOptions): IReadable; /** * 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>;