import { RecursiveArray } from './types' ; export default function flatten < T > ( array , result = [ ] ) { for ( let val of array ) { if ( ! Array . isArray ( val ) ) { result . push ( val ) ; } else { flatten ( val , result ) ; } } return result ; }