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

utils/index-by
v1.1.0
1.1.0
MIT
PUBLIC
3
1     DEPENDENCIES
Build: fail
BuildFail
Build Status: fail
Given a function that generates a key, turns a list of objects into an

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/index-by in your project
npm i @bit/bit.ramda.utils.index-by
Copied

indexBy (fn:Function, array:Array) : Object

Given a function that generates a key, turns a list of objects into an object indexing the objects by the given key. Note that if multiple objects generate the same value for the indexing key only the last value will be included in the generated object.

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

Example

var list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
     R.indexBy(R.prop('id'), list);
     //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}

Arguments

fn: Function

Function :: a -> String

array: Array

The array of objects to index

Returns

Object

An object indexing each array element by the given property.