0.2.0 • Published 8 years ago

ramped.reduce v0.2.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Ramped reduce

Reduce a list of values into a single value. Starts by calling the given function with an initial value and the first item of the list. Then loops the rest of the list, calling the given function with the last returned value and the current item from the list.

The reducer function must accept the current value as the first parameter and the running total as the second parameter. This is the flipped version of Ramda.reduce.

Install

To add as a dependency to a Node.js project:

npm i ramped.reduce --save

Usage

reduce = require('ramped.reduce')

subtract = (item, acc) => acc - item

reduce(subtract, 12, [1, 2, 3])
// 6

License

ISC

0.2.0

8 years ago

0.1.0

8 years ago