UNPKG

1.58 kBTypeScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2export declare class AsyncIterableReadableStream<T> extends AsyncIterableX<T | undefined> {
3 protected _stream: ReadableStream<T>;
4 constructor(_stream: ReadableStream<T>);
5 [Symbol.asyncIterator](): AsyncIterator<T | undefined, any, undefined>;
6}
7export declare class AsyncIterableReadableByteStream extends AsyncIterableReadableStream<Uint8Array> {
8 [Symbol.asyncIterator](): AsyncIterator<Uint8Array | undefined, any, undefined>;
9}
10/**
11 * Creates an async-iterable from an existing DOM stream.
12 *
13 * @export
14 * @template TSource The type of elements in the source DOM stream.
15 * @param {ReadableStream<TSource>} stream The DOM Readable stream to convert to an async-iterable.
16 * @returns {AsyncIterableX<TSource>} An async-iterable containing the elements from the ReadableStream.
17 */
18export declare function fromDOMStream<TSource>(stream: ReadableStream<TSource>): AsyncIterableX<TSource>;
19/**
20 * Creates an async-iterable from an existing DOM stream and options.
21 *
22 * @export
23 * @template TSource * @template TSource The type of elements in the source DOM stream.
24 * @param {ReadableStream<TSource>} stream The readable stream to convert to an async-iterable.
25 * @param {{ mode: 'byob' }} options The options to set the mode for the DOM stream.
26 * @returns {AsyncIterableX<TSource>} An async-iterable created from the incoming async-iterable.
27 */
28export declare function fromDOMStream<TSource extends ArrayBufferView>(stream: ReadableStream<TSource>, options: {
29 mode: 'byob';
30}): AsyncIterableX<TSource>;