MCPcopy Create free account
hub / github.com/Effect-TS/effect / reduce

Function reduce

packages/effect/src/Sink.ts:1457–1463  ·  view source on GitHub ↗
(initial: LazyArg<S>, f: (s: S, input: In) => S)

Source from the content-addressed store, hash-verified

1455 * @since 4.0.0
1456 */
1457export const reduce = <S, In>(initial: LazyArg<S>, f: (s: S, input: In) => S): Sink<S, In> =>
1458 reduceArray(initial, (s, arr) => {
1459 for (let i = 0; i < arr.length; i++) {
1460 s = f(s, arr[i])
1461 }
1462 return s
1463 })
1464
1465/**
1466 * A sink that reduces its inputs using the provided function `f` starting from

Callers

nothing calls this directly

Calls 2

reduceArrayFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected