1.0.1 • Published 9 years ago
@iterables/reduce v1.0.1
@iterables/reduce
A reduce generator for iterators.
const reduce = require('@iterables/reduce')
const value = reduce(function * () {
yield 1
yield 2
}(), (acc, xs) => acc + xs)
console.log(value) // 3Installation
$ npm install --save @iterables/reduceAPI
reduce(iterable, fn[, initial]) -> Value
iterable: anyIterator— a generator instance,Array,Map,String, orSetfn: A function takingacc,xs,idx, andalland returning any value.acc: the accumulator returned byfn. The first value is the first item from the iterable ifinitialis not given.xs: an item fromiterable.idx: a number reflecting the index of the current item.all: the fulliterableobject.
Returns a value representing the reduction of the input iterator.
License
MIT
1.0.1
9 years ago