UNPKG

2.15 kBTypeScriptView Raw
1export declare type ReadableBYOBStreamOptions<T = any> = QueuingStrategy<T> & {
2 type: 'bytes';
3};
4export declare type ReadableByteStreamOptions<T = any> = QueuingStrategy<T> & {
5 type: 'bytes';
6 autoAllocateChunkSize?: number;
7};
8/**
9 * Converts an async-iterable instance to a DOM stream.
10 * @param source The source async-iterable to convert to a DOM stream.
11 * @param strategy The queueing strategy to apply to the DOM stream.
12 */
13export declare function toDOMStream<T>(source: AsyncIterable<T>, strategy?: QueuingStrategy<T>): ReadableStream<T>;
14/**
15 * Converts an async-iterable stream to a DOM stream.
16 * @param source The async-iterable stream to convert to a DOM stream.
17 * @param options The ReadableBYOBStreamOptions to apply to the DOM stream.
18 */
19export declare function toDOMStream<T>(source: AsyncIterable<T>, options: ReadableBYOBStreamOptions<Uint8Array>): ReadableStream<Uint8Array>;
20/**
21 * Converts an async-iterable stream to a DOM stream.
22 * @param source The async-iterable stream to convert to a DOM stream.
23 * @param options The ReadableByteStreamOptions to apply to the DOM stream.
24 */
25export declare function toDOMStream<T>(source: AsyncIterable<T>, options: ReadableByteStreamOptions<Uint8Array>): ReadableStream<Uint8Array>;
26/**
27 * @ignore
28 */
29export declare function toDOMStreamProto<T>(this: AsyncIterable<T>, strategy?: QueuingStrategy<T>): ReadableStream<T>;
30export declare function toDOMStreamProto<T>(this: AsyncIterable<T>, options: ReadableBYOBStreamOptions<Uint8Array>): ReadableStream<Uint8Array>;
31export declare function toDOMStreamProto<T>(this: AsyncIterable<T>, options: ReadableByteStreamOptions<Uint8Array>): ReadableStream<Uint8Array>;
32declare module '../asynciterable/asynciterablex' {
33 interface AsyncIterableX<T> {
34 toDOMStream: typeof toDOMStreamProto;
35 tee(): [ReadableStream<T>, ReadableStream<T>];
36 pipeTo(writable: WritableStream<T>, options?: PipeOptions): Promise<void>;
37 pipeThrough<R extends ReadableStream<any>>(duplex: {
38 writable: WritableStream<T>;
39 readable: R;
40 }, options?: PipeOptions): ReadableStream<T>;
41 }
42}