UNPKG

1.09 kBTypeScriptView Raw
1/// <reference types="node" />
2import { AsyncIterableX } from './asynciterablex';
3export declare class ReadableStreamAsyncIterable extends AsyncIterableX<string | Buffer> implements AsyncIterator<string | Buffer> {
4 private _stream;
5 private _defaultSize?;
6 private _state;
7 private _error;
8 private _rejectFns;
9 private _endPromise;
10 constructor(stream: NodeJS.ReadableStream, size?: number);
11 [Symbol.asyncIterator](): AsyncIterator<string | Buffer>;
12 next(size?: number | undefined): Promise<IteratorResult<string | Buffer>>;
13 private _waitReadable;
14 private _waitEnd;
15}
16/**
17 * Creates a new async-iterable from a Node.js stream.
18 *
19 * @export
20 * @param {NodeJS.ReadableStream} stream The Node.js stream to convert to an async-iterable.
21 * @param {number} [size] The size of the buffers for the stream.
22 * @returns {(AsyncIterableX<string | Buffer>)} An async-iterable containing data from the stream either in string or Buffer format.
23 */
24export declare function fromNodeStream(stream: NodeJS.ReadableStream, size?: number): AsyncIterableX<string | Buffer>;