Skip to main content

Function: flatten()

flatten<Value>(iterable): Iterable<Value, any, any>

Returns an iterable that contains the values of each iterable in iterable in iteration order.

Like Array.prototype.flat, but for iterables.

Type Parameters

Value

Parameters

iterable: Iterable<Iterable<Value, any, any>, any, any>

Returns

Iterable<Value, any, any>

Example

console.log(
pipe(
[[1, 2], [3, `sloth`, 5], [6, 7]],
flatten,
reduce(toArray()),
),
)
//=> [ 1, 2, 3, 'sloth', 5, 6, 7 ]

Defined in

transforms.d.ts:211