@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
30 lines (29 loc) • 1.15 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Readable, Transform } from 'stream';
import { DeferredPromise } from '@naturalcycles/js-lib';
declare type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
export interface PipelineOptions {
/**
* Set to true to allow ERR_STREAM_PREMATURE_CLOSE.
* Required to support graceful close when using transformLimit
*/
allowClose?: boolean;
}
/**
* Promisified `stream.pipeline`.
*
* Supports opt.allowClose, which allows transformLimit to work (to actually stop source Readable)
* without throwing an error (ERR_STREAM_PREMATURE_CLOSE).
*/
export declare function _pipeline(streams: AnyStream[], opt?: PipelineOptions): Promise<void>;
/**
* Convenience function to make _pipeline collect all items at the end of the stream (should be Transform, not Writeable!)
* and return.
*/
export declare function _pipelineToArray<T>(streams: AnyStream[], opt?: PipelineOptions): Promise<T[]>;
export declare class AbortableTransform extends Transform {
sourceReadable?: Readable;
streamDone?: DeferredPromise;
}
export {};