/// import { Readable } from 'stream'; import { CommonLogger } from '@naturalcycles/js-lib'; import { AbortableTransform } from '../../index'; import { TransformOptions, TransformTyped } from '../stream.model'; export interface TransformLimitOptions extends TransformOptions { /** * Nullish value (e.g 0 or undefined) would mean "no limit" */ limit?: number; /** * If provided (recommended!) - it will call readable.destroy() on limit. * Without it - it will only stop the downstream consumers, but won't stop * the Readable ("source" of the stream). * It is almost always crucial to stop the Source too, so, please provide the Readable here! */ sourceReadable?: Readable; /** * Please provide it (a Promise that resolves when the Stream is done, e.g finished consuming things) * to be able to wait for Consumers before calling `readable.destroy`. * Has no effect if `readable` is not provided. */ streamDone?: Promise; logger?: CommonLogger; /** * Set to true to enable additional debug messages, e.g it'll log * when readable still emits values after the limit is reached. */ debug?: boolean; } /** * Class only exists to be able to do `instanceof TransformLimit` * and to set sourceReadable+streamDone to it in `_pipeline`. */ export declare class TransformLimit extends AbortableTransform { } /** * 0 or falsy value means "no limit" */ export declare function transformLimit(opt?: TransformLimitOptions): TransformTyped;