1 |
|
2 | import { BufferLike } from '../interfaces';
|
3 | import { Readable, ReadableOptions } from 'stream';
|
4 | declare type AsyncSourceIterator<TSource> = AsyncIterator<TSource, any, number | ArrayBufferView | undefined | null>;
|
5 | export declare class AsyncIterableReadable<T> extends Readable {
|
6 | private _pulling;
|
7 | private _objectMode;
|
8 | private _iterator;
|
9 | constructor(source: AsyncIterable<T>, options?: ReadableOptions);
|
10 | _read(size: number): void;
|
11 | _destroy(err: Error | null, cb: (err: Error | null) => void): void;
|
12 | _pull(it: AsyncSourceIterator<T>, size: number): Promise<boolean>;
|
13 | }
|
14 | /**
|
15 | * Converts an existing async-iterable to a Node.js stream.
|
16 | * @param source The async-iterable to convert to a Node.js stream.
|
17 | * @param options The optional Readable options for the Node.js stream.
|
18 | */
|
19 | export declare function toNodeStream<TSource>(source: AsyncIterable<TSource>): AsyncIterableReadable<TSource>;
|
20 | export declare function toNodeStream<TSource>(source: AsyncIterable<TSource>, options: ReadableOptions & {
|
21 | objectMode: true;
|
22 | }): AsyncIterableReadable<TSource>;
|
23 | export declare function toNodeStream<TSource extends BufferLike>(source: AsyncIterable<TSource>, options: ReadableOptions & {
|
24 | objectMode: false;
|
25 | }): AsyncIterableReadable<TSource>;
|
26 | /**
|
27 | * @ignore
|
28 | */
|
29 | export declare function toNodeStreamProto<TSource>(this: AsyncIterable<TSource>): AsyncIterableReadable<TSource>;
|
30 | export declare function toNodeStreamProto<TSource>(this: AsyncIterable<TSource>, options: ReadableOptions & {
|
31 | objectMode: true;
|
32 | }): AsyncIterableReadable<TSource>;
|
33 | export declare function toNodeStreamProto<TSource extends BufferLike>(this: AsyncIterable<TSource>, options: ReadableOptions & {
|
34 | objectMode: false;
|
35 | }): AsyncIterableReadable<TSource>;
|
36 | declare module '../asynciterable/asynciterablex' {
|
37 | interface AsyncIterableX<T> {
|
38 | toNodeStream: typeof toNodeStreamProto;
|
39 | }
|
40 | }
|
41 | export {};
|