import _ from 'lodash' ; export function arrayTreeFilter < T > ( data , filterFn , options ? ) { options = options || { } ; options . childrenKeyName = options . childrenKeyName || 'children' ; var children = data || [ ] ; var result = [ ] ; var level = 0 ; do { var foundItem = children . filter ( function ( item ) { return filterFn ( item , level ) ; } ) [ 0 ] ; if ( ! foundItem ) { break ; } result . push ( foundItem ) ; children = ( foundItem as any ) [ options . childrenKeyName ] || [ ] ; level += 1 ; } while ( children . length > 0 ) ; return result ; } param length param i returns export const last = ( length , i ) => length - 1 === i ;