license /**
 * The flat() method creates a new array with all sub-array elements concatenated into it.
 * Unlike Array.prototoype.flat, does not support recursively flattening up to the specified depth.
 */ export function flatPolyfill < U > ( arr , depth ? ) { const flatOnce = ( arr ) => arr . reduce ( ( acc , val ) => acc . concat ( val ) , [ ] ) ; let ret = flatOnce ( arr ) ; if ( depth ) { for ( let i = 1 ; i < depth ; i ++ ) { ret = flatOnce ( ret ) ; } } return ret ; } export function flat < U = { } > ( arr , depth ? ) { if ( 'flat' in Array . prototype ) { return arr . flat ( depth ) ; } else { return flatPolyfill ( arr ) ; } }