license /**
 * The flatMap() method first maps each element using a mapping function, then flattens the result into a new array.
 * It is identical to a map followed by a flat of depth 1.
 */ export function flatMapPolyfill < T , U > ( arr , callback ) { return arr . reduce ( ( acc , x , i , arr ) => { const val = callback ( x , i , arr ) ; if ( Array . isArray ( val ) ) { return acc . concat ( val ) ; } else { acc . push ( val as U ) ; return acc ; } } , [ ] ) ; } export function flatMap < T , U , This = undefined > ( arr , callback , thisArg ? ) { if ( 'flatMap' in Array . prototype ) { return arr . flatMap ( callback ) ; } else { return flatMapPolyfill ( arr , callback ) ; } }