Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

ianstormtaylor/reduce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reduce

Reduce an object or array.

Installation

$ component install ianstormtaylor/reduce

Example

Arrays:

var reduce = require('reduce');

reduce([1, 2, 3], 0, function (curr, val, i) {
  return curr + val;
});

// 6

Objects:

var reduce = require('reduce');

reduce({ a: 1, b: 2, c: 3 }, 0, function (curr, key, val) {
  return curr + val;
});

// 6

API

reduce(obj, memo, iterator)

Reduce the obj using an iterator and starting with the memo.

License

MIT

About

Reduce an array or object.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published