Hyperlinkv0.8.0-beta.28

Array

Array.flattenconsteffect/Array.ts:3571
<const S extends ReadonlyArray<ReadonlyArray<any>>>(
  self: S
): ReadonlyArray.Flatten<S>

Flattens a nested array of arrays into a single array.

When to use

Use to collapse one level of nested arrays when no per-element mapping is needed.

Example (Flattening nested arrays)

import { Array } from "effect"

console.log(Array.flatten([[1, 2], [], [3, 4], [], [5, 6]])) // [1, 2, 3, 4, 5, 6]
sequencingflatMap
Source effect/Array.ts:35712 lines
export const flatten: <const S extends ReadonlyArray<ReadonlyArray<any>>>(self: S) => ReadonlyArray.Flatten<S> =
  flatMap(identity) as any