Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / concatMap

Function: concatMap()

concatMap<T, R>(project): Operator<T, R>

Defined in: projects/libraries/streamix/src/lib/operators/concatMap.ts:24

Creates a stream operator that maps each value from the source stream to a new inner stream (or value/array/promise) and flattens all inner streams sequentially.

For each value from the source:

  1. The project function is called with the value and its index.
  2. The returned value is normalized into a stream using fromAny.
  3. The inner stream is consumed fully before processing the next outer value.

This ensures that all emitted values maintain their original sequential order.

Type Parameters

T

T = any

The type of values in the source stream.

R

R = T

The type of values emitted by the inner streams and the output.

Parameters

project

(value, index) => Stream<R> | MaybePromise<R> | R[]

A function that takes a value from the source stream and its index, and returns either:

  • a <R>,
  • a <R> (value or promise),
  • or an array of R.

Returns

Operator<T, R>

An Operator instance that can be used in a stream's pipe method.

Released under the MIT License.