Arrays.reduce()

Run some logic (the "iteratee") once for each item of an array, accumulating a single result.

Usage

Hover over inputs/exits for more info.

var Arrays = require('machinepack-arrays');


// Run some logic (the "iteratee") once for each item of an array, accumulating a single result.

Arrays.reduce({

array: [ '*' ],

iteratee: '->',

resultExemplar: ,

initialValue: '*',

series: true,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function () {

 

},

});

Inputs

array required

The array to loop over

[ '*' ]
iteratee required

The function to run for each item in the array.

'->'
resultExemplar

An example of what the final accumulated result will look like.

initialValue

The initial value for the accumulated result

'*'
series

Whether to run iteratee on all items in series (one at a time) vs. in parallel (all at the same time)

true

Exits

error

An unexpected error occurred.

success

OK.

(varies based on provided inputs)