MCPcopy Create free account
hub / github.com/effect-app/libs / reduceArray

Function reduceArray

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

Source from the content-addressed store, hash-verified

1371 if (!predicate(state)) {
1372 return Cause.done()
1373 }
1374 return Effect.void
1375 }),
1376 Effect.forever({ disableYield: true }),
1377 Pull.catchDone(() => Effect.succeed([state] as const))
1378 )
1379 })
1380
1381/**
1382 * A sink that reduces its inputs using the provided function `f` starting from
1383 * the provided `initial` state.
1384 *
1385 * @category folding
1386 * @since 4.0.0
1387 */
1388export const reduce = <S, In>(initial: LazyArg<S>, f: (s: S, input: In) => S): Sink<S, In> =>
1389 reduceArray(initial, (s, arr) => {
1390 for (let i = 0; i < arr.length; i++) {

Callers 3

reduceFunction · 0.85
Sink.tsFile · 0.85
collectFunction · 0.85

Calls 5

initialFunction · 0.85
fromTransformFunction · 0.70
pipeMethod · 0.65
fFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…