UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

16 lines (12 loc) 330 B
import { isArray } from './_internals/isArray.js' export function flatten(list, input){ const willReturn = input === undefined ? [] : input for (let i = 0; i < list.length; i++){ if (isArray(list[ i ])){ flatten(list[ i ], willReturn) } else { willReturn.push(list[ i ]) } } return willReturn }