method StreamClass.prototype.flatMap
Private
StreamClass.prototype.flatMap<U>(fn: (
value: T,
index: number
) => Source<U>
): StreamClass<Exclude<U, AnyFailure>, E | Extract<U, AnyFailure>>

Expands each value into a source and flattens it in order — pages into rows, rows into cells. Failure elements pass through unexpanded.

await Stream.from([[1, 2], [3]]).flatMap((page) => page).collect(); // [1, 2, 3]

Type Parameters

Parameters

fn: (
value: T,
index: number
) => Source<U>

Return Type

StreamClass<Exclude<U, AnyFailure>, E | Extract<U, AnyFailure>>

Usage

import { StreamClass } from "lib/stream/stream.ts";