import { flatten } from './flatten' ; import { purry } from './purry' ; param array param fn signature example data_first pipeable category export function flatMap < T , K > ( array , fn ) ; param array param fn signature example data_last pipeable category export function flatMap < T , K > ( fn ) ; export function flatMap ( ) { return purry ( _flatMap , arguments , flatMap . lazy ) ; } function _flatMap < T , K > ( array , fn ) { return flatten ( array . map ( item => fn ( item ) ) ) ; } export namespace flatMap { export function lazy < T , K > ( fn ) { return ( value ) => { const next = fn ( value ) ; if ( Array . isArray ( next ) ) { return { done : false , hasNext : true , hasMany : true , next : next , } ; } return { done : false , hasNext : true , next , } ; } ; } }