Skip to content

Latest commit

 

History

History
31 lines (18 loc) · 1.31 KB

polyethylene.polyasynciterable.reduce_1.md

File metadata and controls

31 lines (18 loc) · 1.31 KB

Home > polyethylene > PolyAsyncIterable > reduce

PolyAsyncIterable.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.

Signature:

reduce<U>(reducer: AsyncIndexedReducer<T, U>, init: U): Promise<U>;

Parameters

Parameter Type Description
reducer AsyncIndexedReducer<T, U> A function to call for all elements with the result of a previous call
init U First element to be passed to the reducer function

Returns:

Promise<U>

A promise 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.