interface NamedCount { name : string ; count : number ; } export function appendOtherGroup ( list ) { let unknownItemCount = 0 ; if ( ! list ) { return [ [ ] , unknownItemCount ] ; } const otherItem = { name : 'Other' , count : 0 } ; const filteredList = [ ] ; list . forEach ( ( item ) => { if ( item . name === 'tmp' || item . name === 'eth2' || item . name === '' ) { unknownItemCount += item . count ; } else if ( filteredList . length > 9 ) { otherItem . count += item . count ; } else { filteredList . push ( item ) ; } } ) ; if ( otherItem . count > 0 ) { filteredList . push ( otherItem ) ; } return [ filteredList , unknownItemCount ] ; }