Skip to main content

Variable: flatten()

const flatten: <Value>(iterable) => Iterable<Value>

Defined in: transforms.d.ts:339

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

Value

Parameters

iterable

Iterable<Iterable<Value>>

Returns

Iterable<Value>

Example

import { flatten, pipe, reduce, toArray } from 'lfi'

console.log(
pipe(
[[`sloth`, `lazy`], [`sleep`]],
flatten,
reduce(toArray()),
),
)
//=> [ 'sloth', 'lazy', 'sleep' ]
Playground

Since

v0.0.1