starry.reduce

4.0.0 • Public • Published

Member of the starry suite—modular functions for iterable objects.

npm node

Status

Applies to the whole suite.

Build Status Coverage Status

Usage

function reduce<T = any>(
  iterable: Iterable<T>, 
  accumulator: (previousValue: T, currentValue: T) => T
  ): T
function reduce<T = any, U = any>(
  iterable: Iterable<T>,
  accumulator: (previousValue: U, currentValue: T) => U,
  initialValue: U
  ): U

Applies an accumulator function over an iterable.

Parameters:

  • iterable: Iterable<T>
  • accumulator: (previousValue, currentValue) - An accumulator function over the iterable.
    • previousValue - The accumulate or the initial value.
    • current - The current item of the iterable. Must return - The new accumulate.
  • initialValue - Optional via argument length. The initial accumulator value.

This works like Array.prototype.reduce.

Package Sidebar

Install

npm i starry.reduce

Weekly Downloads

0

Version

4.0.0

License

MIT

Unpacked Size

6.25 kB

Total Files

9

Last publish

Collaborators

  • seangenabe