just-group-by
v2.2.0
Published
return a grouped object from array
Downloads
74,957
Maintainers
Readme
just-group-by
Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.
npm install just-group-by
yarn add just-group-by
Return a grouped object from array
import groupBy from 'just-group-by';
groupBy([6.1, 4.2, 6.3], Math.floor); // { '4': [4.2], '6': [6.1, 6.3] }
groupBy([1,2,3,4,5,6,7,8], function(i) { return i % 2}); // { '0': [2, 4, 6, 8], '1': [1, 3, 5, 7] }