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

utils/add-index
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Creates a new list iteration function from an existing one by adding two new

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

addIndex (fn:Function) : Function

Creates a new list iteration function from an existing one by adding two new parameters to its callback function: the current index, and the entire list.

This would turn, for instance, R.map function into one that more closely resembles Array.prototype.map. Note that this will only work for functions in which the iteration callback function is the first parameter, and where the list is the last parameter. (This latter might be unimportant if the list parameter is not used.)

Example

var mapIndexed = R.addIndex(R.map);
     mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
     //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']

Argument

fn: Function

A list iteration function that does not pass index or list to its callback

Returns

Function

An altered list iteration function that passes (item, index, list) to its callback