export const countEmotes = ( reactions = [ ] ) => { const emoteCounts = { } ; reactions . forEach ( ( { emote } ) => { emoteCounts [ emote ] = emoteCounts [ emote ] ? emoteCounts [ emote ] + 1 : 1 ; } ) ; return Object . entries ( emoteCounts ) . map ( ( [ emoji , count ] ) => ( { emoji , count } ) ) . sort ( ( a , b ) => a . count - b . count ) . slice ( - 5 ) ; } ;