Function
make
(
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 | */ |
| 117 | export 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. |
Tested by
no test coverage detected