dist/utilify.esm.js
function groupObjectByValue(item, key) {
        var camelize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

        if (!validateHelpers.isArray(item)) {
            throw new Error('\'item\' must be an array of objects');
        }

        var grouped = item.reduce(function (r, a) {
            r[a[key]] = r[a[key]] || [];
            r[a[key]].push(a);
            return r;
        }, Object.create(null));

        return camelize ? globalHelpers.camelize(grouped) : grouped;
    }
function groupObjectByValue(item, key) {
        var camelize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

        if (!validateHelpers.isArray(item)) {
            throw new Error('\'item\' must be an array of objects');
        }

        var grouped = item.reduce(function (r, a) {
            r[a[key]] = r[a[key]] || [];
            r[a[key]].push(a);
            return r;
        }, Object.create(null));

        return camelize ? globalHelpers.camelize(grouped) : grouped;
    }
function groupObjectByValue ( item , key ) { var camelize = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : false ; if ( ! validateHelpers . isArray ( item ) ) { throw new Error ( '\'item\' must be an array of objects' ) ; } var grouped = item . reduce ( function ( r , a ) { r [ a [ key ] ] = r [ a [ key ] ] || [ ] ; r [ a [ key ] ] . push ( a ) ; return r ; } , Object . create ( null ) ) ; return camelize ? globalHelpers . camelize ( grouped ) : grouped ; }
Group an array of objects by same properties value
Returns new object with a key grouped values

@param  {Array}   item       An array of objects
@param  {String}  key        The key where the values are grouped
@param  {Boolean} camelize   Camlize key (e.g. 'John Smith' or 'john-smith' turn into johnSmith)
@returns {Object}
@example
const objToGroup = [
{ name: 'John', age: 20 },
{ name: 'Mary', age: 20 },
{ name: 'Smith', age: 18 },
{ name: 'John', age: 22 }
];

groupObjectByValue(objToGroup, 'age') // { 18: [{ name: 'Smith', age: 18 }], 20: [{ name: 'John', age: 20 }, { name: 'Mary', age: 20 }], 22: { name: 'John', age: 22 } }
groupObjectByValue(objToGroup, 'name', true) // { john: [{ name: 'John', age: 22 }, { name: 'John', age: 20 }], mary: [{ name: 'Mary', age: 20 }], smith: [{ name: 'Smith', age: 18 }] }
Group an array of objects by same properties value Returns new object with a key grouped values