UNPKG

1.15 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3import { Readable, Transform } from 'node:stream';
4import { DeferredPromise } from '@naturalcycles/js-lib';
5type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
6export interface PipelineOptions {
7 /**
8 * Set to true to allow ERR_STREAM_PREMATURE_CLOSE.
9 * Required to support graceful close when using transformLimit
10 */
11 allowClose?: boolean;
12}
13/**
14 * Promisified `stream.pipeline`.
15 *
16 * Supports opt.allowClose, which allows transformLimit to work (to actually stop source Readable)
17 * without throwing an error (ERR_STREAM_PREMATURE_CLOSE).
18 */
19export declare function _pipeline(streams: AnyStream[], opt?: PipelineOptions): Promise<void>;
20/**
21 * Convenience function to make _pipeline collect all items at the end of the stream (should be Transform, not Writeable!)
22 * and return.
23 */
24export declare function _pipelineToArray<T>(streams: AnyStream[], opt?: PipelineOptions): Promise<T[]>;
25export declare class AbortableTransform extends Transform {
26 sourceReadable?: Readable;
27 streamDone?: DeferredPromise;
28}
29export {};