Share your code. Components are building blocks, you are the architect.

utils/group-by
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Splits a list into sub-lists stored in an object, based on the result of

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/group-by in your project
npm i @bit/bit.ramda.utils.group-by
Copied

groupBy (fn:Function, list:Array) : Object

Splits a list into sub-lists stored in an object, based on the result of calling a String-returning function on each element, and grouping the results according to values returned.

Dispatches to the groupBy method of the second argument, if present.

Acts as a transducer if a transformer is given in list position.

Example

var byGrade = R.groupBy(function(student) {
       var score = student.score;
       return score < 65 ? 'F' :
              score < 70 ? 'D' :
              score < 80 ? 'C' :
              score < 90 ? 'B' : 'A';
     });
     var students = [{name: 'Abby', score: 84},
                     {name: 'Eddy', score: 58},
                     // ...
                     {name: 'Jack', score: 69}];
     byGrade(students);
     // {
     //   'A': [{name: 'Dianne', score: 99}],
     //   'B': [{name: 'Abby', score: 84}]
     //   // ...,
     //   'F': [{name: 'Eddy', score: 58}]
     // }

Arguments

fn: Function

Function :: a -> String

list: Array

The array to group

Returns

Object

An object with the output of `fn` for keys, mapped to arrays of elements that produced that key when passed to `fn`.