UNPKG

1.15 kBTypeScriptView Raw
1/// <reference types="node" />
2import { ReadableOptions } from 'node:stream';
3import { ReadableTyped } from '../stream.model';
4/**
5 * Convenience function to create a Readable that can be pushed into (similar to RxJS Subject).
6 * Push `null` to it to complete (similar to RxJS `.complete()`).
7 *
8 * Difference from Readable.from() is that this readable is not "finished" yet and allows pushing more to it.
9 *
10 * Caution!
11 * The implementation of this Readable is not fully compliant,
12 * e.g the read() method doesn't return anything, so, it will hand the Node process (or cause it to process.exit(0))
13 * if read() will be called AFTER everything was pushed and Readable is closed (by pushing `null`).
14 * Beware of it when e.g doing unit testing! Jest prefers to hang (not exit-0).
15 *
16 * @deprecated because of the caution above
17 */
18export declare function readableCreate<T>(items?: Iterable<T>, opt?: ReadableOptions): ReadableTyped<T>;
19/**
20 * Convenience type-safe wrapper around Readable.from() that infers the Type of input.
21 */
22export declare function readableFrom<T>(items: Iterable<T> | AsyncIterable<T>, opt?: ReadableOptions): ReadableTyped<T>;