import type { L } from 'ts-toolbelt' ; import { reduce } from './reduce' ; import { concat } from './concat' ; function wrap ( item ) { return Array . isArray ( item ) ? item : [ item ] ; } type Flatten < L extends L . List , I = L [ number ] > = ( I extends L . List ? I [ number ] : I ) [ ] & { } ; param list returns function flatten < L extends L . List , I > ( list ) { return reduce ( list , ( acc , item ) => concat ( acc , wrap ( item ) ) , [ ] as any [ ] ) ; } export { flatten } ;