import { noop } from './noop' ; export function forEach < T > ( target , eachFunc , inverse ? ) ; export function forEach < T > ( target , eachFunc , inverse ? ) ; export function forEach ( target , eachFunc , inverse ? ) ; export function forEach ( target , eachFunc , inverse ? ) { let length ; let handler = eachFunc ; if ( target instanceof Set || target instanceof Map ) { ( target as any ) . forEach ( ( value , key ) => { if ( handler ( value , key ) === false ) { handler = noop ; } } ) ; } else if ( target instanceof Array ) { length = target . length ; if ( ! inverse ) { let i = - 1 ; while ( ++ i < length ) { if ( eachFunc ( target [ i ] , i ) === false ) { break ; } } } else { let i = length ; while ( i -- ) { if ( eachFunc ( target [ i ] , i ) === false ) { break ; } } } } else if ( typeof target === 'object' ) { const keys = Object . keys ( target ) ; let key ; length = keys . length ; let i = - 1 ; while ( ++ i < length ) { key = keys [ i ] ; if ( eachFunc ( target [ key ] , key ) === false ) { break ; } } } }