import { _reduceLazy , LazyResult } from './_reduceLazy' ; import { purry } from './purry' ; type Flatten < T > = T extends ReadonlyArray < infer K > ? K : T ; param items signature example category pipeable export function flatten < T > ( items ) ; export function flatten < T > ( ) ; export function flatten ( ) { return purry ( _flatten , arguments , flatten . lazy ) ; } function _flatten < T > ( items ) { return _reduceLazy ( items , flatten . lazy ( ) ) ; } export namespace flatten { export function lazy < T > ( ) { return ( next ) : LazyResult < any > => { if ( Array . isArray ( next ) ) { return { done : false , hasNext : true , hasMany : true , next : next , } ; } return { done : false , hasNext : true , next , } ; } ; } }