import { AsyncMapper, AsyncPredicate, ErrorMode } from '@naturalcycles/js-lib'; import { TransformTyped } from '../stream.model'; export interface TransformMapOptions { /** * @default true */ objectMode?: boolean; /** * @default false * Set true to support "multiMap" - possibility to return [] and emit 1 result for each item in the array. */ flattenArrayOutput?: boolean; /** * Predicate to filter outgoing results (after mapper). * Allows to not emit all results. * * @default to filter out undefined/null values, but pass anything else * * Set to `r => r` (passthrough predicate) to pass ANY value (including undefined/null) */ predicate?: AsyncPredicate; /** * Number of concurrently pending promises returned by `mapper`. * * @default 16 (to match default highWatermark option for objectMode streams) */ concurrency?: number; /** * @default THROW_IMMEDIATELY */ errorMode?: ErrorMode; /** * If defined - will be called on every error happening in the stream. * Called BEFORE observable will emit error (unless skipErrors is set to true). */ onError?: (err: unknown, input: IN) => any; /** * Progress metric * * @default `stream` */ metric?: string; /** * If defined - called BEFORE `final()` callback is called. */ beforeFinal?: () => any; /** * If defined - called AFTER final chunk was processed. */ afterFinal?: () => any; } export declare function notNullishPredicate(item: any): boolean; /** * Like pMap, but for streams. * Inspired by `through2`. * Main feature is concurrency control (implemented via `through2-concurrent`) and convenient options. * Using this allows native stream .pipe() to work and use backpressure. * * Only works in objectMode (due to through2Concurrent). * * Concurrency defaults to 16. * * If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray(). */ export declare function transformMap(mapper: AsyncMapper, opt?: TransformMapOptions): TransformTyped;