Function groupBy

Groups an array of items by a key returned by a mapping function.

const getLength = (item: string) => item.length;
groupBy(getLength)(['a', 'bb', 'c', 'dd']); // => { '1': ['a', 'c'], '2': ['bb', 'dd'] }