import type { L } from 'ts-toolbelt'; import type { RequiredProps } from './Object.js'; import type { UnderlyingDefaultSource, UnderlyingSink } from 'node:stream/web'; /** * Something that can be flushed by another stream. * * @group Utils * @category Stream */ export interface Flushable { flushes?: ReadableStream; /** * By default an error in the `flushes` stream will be sent by the transformer. */ ignoreFlushErrors?: boolean; } /** * Using a {@link Flushable} notify when the stream * flushes and errors. * * @group Utils * @category Stream */ export declare function pipeFlushes(onFlush: () => void | Promise, onError: (error: unknown) => unknown, options?: Flushable & { signal?: AbortSignal; }): void; /** * Returns the chunk type of a ReadableStream. * * @group Utils * @category Stream * @example * ``` * type T = ReadableStreamChunk> * // number * ``` */ export type ReadableStreamChunk> = R extends ReadableStream ? T : never; /** * Returns the union chunk type of a list of ReadableStreams. * * @group Utils * @category Stream * @example * ``` * type T = ReadableStreamsChunk<[ReadableStream, ReadableStream]> * // number | string * ``` */ export type ReadableStreamsChunk[]> = RSs extends ReadableStream[] ? T : never; /** * Creates a tuple type of the chunk types from a list of * ReadableStreams. * * @group Utils * @category Stream * @example * ``` * type T = ReadableStreamsChunks<[ * ReadableStream, * ReadableStream, * ReadableStream, * ReadableStream, * ]> * // [number, string, string, number] * ``` */ export type ReadableStreamsChunks[]> = _ReadableStreamsChunks; type _ReadableStreamsChunks[], Acc extends unknown[]> = L.Length extends 0 ? Acc : _ReadableStreamsChunks, [ ...Acc, ReadableStreamChunk> ]>; /** * An underlying source that immediately closes. * * @group Sources */ export declare function immediatelyClosingUnderlyingSource(): UnderlyingDefaultSource; /** * Creates a ReadableStream that immediately closes. * * @group Sources */ export declare function immediatelyClosingReadableStream(): import("node:stream/web").ReadableStream; export declare function mergeUnderlyingSource[]>(readableStreams: RSs | (() => RSs)): UnderlyingDefaultSource>; /** * Merges multiple streams in to 1 ReadableStream. * * Warning: this may create a bottleneck as the highwater mark * can easily be breached. This is because every pull will attempt to * read and queue at least one chunk from each incoming stream. * * @group Sources * @see {@link roundRobin:function} * @example * ``` * merge([ * --1----2-----3-------4------| * ---one---two---three---four-| * ]) * * -1-one-2-two-3-three-4-four-| * ``` */ export declare function merge[]>(readableStreams: RSs | (() => RSs), queuingStrategy?: QueuingStrategy>): import("node:stream/web").ReadableStream>; /** * Consume chunks from a ReadableStream. Syntactical sugar * for a simple WritableStream. * * @group Sinks * @example * ``` * readableStream.pipeTo(write(console.info)) * * // ... instead of ... * * readableStream.pipeTo(new WritableStream({ * write(chunk) { * console.info(chunk) * } * })) * ``` */ export declare function write(fn?: (chunk: T) => unknown, queuingStrategy?: QueuingStrategy): import("node:stream/web").WritableStream; /** * An `UnderlyingDefaultSource` object that has a `cancel` method. * * @group Utils * @category Stream */ export type CancellableSource = RequiredProps, 'cancel'>; /** * A guard to test that an `UnderlyingDefaultSource` object that has a `cancel` method. * * @group Utils * @category Stream */ export declare function isCancellableSource(source: UnderlyingDefaultSource): source is CancellableSource; /** * An `UnderlyingDefaultSource` object that has a `pull` method. * * @group Utils * @category Stream */ export type PullableSource = RequiredProps, 'pull'>; /** * A guard to test that an `UnderlyingDefaultSource` object that has a `pull` method. * * @group Utils * @category Stream */ export declare function isPullableSource(source: UnderlyingDefaultSource): source is PullableSource; /** * An `UnderlyingDefaultSource` object that has a `start` method. * * @group Utils * @category Stream */ export type StartableSource = RequiredProps, 'start'>; /** * A guard to test that an `UnderlyingDefaultSource` object that has a `start` method. * * @group Utils * @category Stream */ export declare function isStartableSource(source: UnderlyingDefaultSource): source is StartableSource; /** * An `UnderlyingSink` object that has an `abort` method. * * @group Utils * @category Stream */ export type AbortableSink = RequiredProps, 'abort'>; /** * A guard to test that an `UnderlyingSink` object that has an `abort` method. * * @group Utils * @category Stream */ export declare function isAbortableSink(sink: UnderlyingSink): sink is AbortableSink; /** * An `UnderlyingSink` object that has a `close` method. * * @group Utils * @category Stream */ export type ClosableSink = RequiredProps, 'close'>; /** * A guard to test that an `UnderlyingSink` object that has a `close` method. * * @group Utils * @category Stream */ export declare function isClosableSink(sink: UnderlyingSink): sink is ClosableSink; /** * An `UnderlyingSink` object that has a `start` method. * * @group Utils * @category Stream */ export type StartableSink = RequiredProps, 'start'>; /** * A guard to test that an `UnderlyingSink` object that has a `start` method. * * @group Utils * @category Stream */ export declare function isStartableSink(sink: UnderlyingSink): sink is StartableSink; /** * An `UnderlyingSink` object that has a `write` method. * * @group Utils * @category Stream */ export type WritableSink = RequiredProps, 'write'>; /** * A guard to test that an `UnderlyingSink` object that has a `write` method. * * @group Utils * @category Stream */ export declare function isWritableSink(sink: UnderlyingSink): sink is WritableSink; export {}; //# sourceMappingURL=Stream.d.ts.map