Darkhogg/polyethylene

View on GitHub
docs/polyethylene.polysynciterable.reduce_1.md

Summary

Maintainability
Test Coverage
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [polyethylene](./polyethylene.md) &gt; [PolySyncIterable](./polyethylene.polysynciterable.md) &gt; [reduce](./polyethylene.polysynciterable.reduce_1.md)

## PolySyncIterable.reduce() method

Returns the result of calling the passed `reducer` for all elements of the iteration and the result of the previous call to `reducer`<!-- -->, starting by passing `init`<!-- -->.

<b>Signature:</b>

```typescript
reduce<U>(reducer: IndexedReducer<T, U>, init: U): U;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  reducer | [IndexedReducer](./polyethylene.indexedreducer.md)<!-- -->&lt;T, U&gt; | A function to call for all elements with the result of a previous call |
|  init | U | First element to be passed to the <code>reducer</code> function |

<b>Returns:</b>

U

The result to continually call `reducer` with all elements and the previous result

## Remarks

`reducer` will be called with the accumulated result, the next element of the iteration, and the index of the iteration. The resolved return value will be the value passed to the next call as the first argument, or the value returned if no more elements remain.