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

utils/map-accum
v1.0.0
1.0.0
MIT
PUBLIC
0
1     DEPENDENCIES
Build: none
BuildNone
The `mapAccum` function behaves like a combination of map and reduce; it

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

mapAccum (fn:Function, acc:*, list:Array) : *

The mapAccum function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.

The iterator function receives two arguments, acc and value, and should return a tuple [acc, value].

Example

var digits = ['1', '2', '3', '4'];
     var appender = (a, b) => [a + b, a + b];

     R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']]

Arguments

fn: Function

The function to be called on every element of the input `list`.

acc: *

The accumulator value.

list: Array

The list to iterate over.

Returns

*

The final, accumulated value.