Socket
Book a DemoInstallSign in
Socket

@iterables/reduce

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iterables/reduce

a reduce function for iterables

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

@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) // 3

Installation

$ npm install --save @iterables/reduce

API

reduce(iterable, fn[, initial]) -> Value

  • iterable: any Iterator — a generator instance, Array, Map, String, or Set
  • fn: A function taking acc, xs, idx, and all and returning any value.
    • acc: the accumulator returned by fn. The first value is the first item from the iterable if initial is not given.
    • xs: an item from iterable.
    • idx: a number reflecting the index of the current item.
    • all: the full iterable object.

Returns a value representing the reduction of the input iterator.

License

MIT

FAQs

Package last updated on 08 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts