flatMap

fun flatMap(fn: (data: Any?, options: ArrayOptions?) -> Any?, options: ArrayOptions = definedExternally): Readable(source)

This method returns a new stream by applying the given callback to each chunk of the stream and then flattening the result.

It is possible to return a stream or another iterable or async iterable from fn and the result streams will be merged (flattened) into the returned stream.

Since

v17.5.0

Parameters

fn

a function to map over every chunk in the stream. May be async. May be a stream or generator.