UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

10 lines (8 loc) 253 B
import { getValueOr } from "./main.ts"; export function flatten<A = any>(coll: any[]): A[] { const flat: any[] = []; getValueOr([], coll).forEach((el) => Array.isArray(el) ? el.forEach((x) => flat.push(x)) : flat.push(el) ); return flat; }