Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.08 KB

.verb.md

File metadata and controls

59 lines (39 loc) · 1.08 KB

{%= name %} {%= badge("fury") %} {%= badge("travis") %}

{%= description %}

{%= include("install-npm", {save: true}) %}

Usage

Callback params

The callback is executed on every element in the supplied array:

  • prev: this is the "accumulator". This value is either the result of the last callback invocation, or the initial value if specified.
  • curr: the current array element being looped over
  • i: the index of the current element
  • arr: the array that is being looped over.

Examples

var reduce = require('{%= name %}');

reduce([1, 2, 3, 4, 5], function (prev, curr) {
  return prev + curr;
});
//=> '15'

Pass an initial value:

reduce(['b', 'c'], function (prev, curr) {
  return prev.concat(curr);
}, ['a']);

//=> ['a', 'b', 'c']

Run tests

Install dev dependencies:

npm i -d && npm

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %})

Author

{%= include("author") %}

License

{%= copyright() %} {%= license() %}


{%= include("footer") %}