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

Function make

packages/effect/src/Reducer.ts:117–134  ·  view source on GitHub ↗
(
  combine: (self: A, that: A) => A,
  initialValue: A,
  combineAll?: (collection: Iterable<A>) => A
)

Source from the content-addressed store, hash-verified

115 * @since 4.0.0
116 */
117export function make<A>(
118 combine: (self: A, that: A) => A,
119 initialValue: A,
120 combineAll?: (collection: Iterable<A>) => A
121): Reducer<A> {
122 return {
123 combine,
124 initialValue,
125 combineAll: combineAll ??
126 ((collection) => {
127 let out = initialValue
128 for (const value of collection) {
129 out = combine(out, value)
130 }
131 return out
132 })
133 }
134}
135
136/**
137 * Reverses the argument order of a reducer's `combine` method.

Callers 1

flipFunction · 0.70

Calls 1

combineFunction · 0.50

Tested by

no test coverage detected