Type Alias: RawOptionalReducerWithFinish<Value, Finished, This>
RawOptionalReducerWithFinish<
Value
,Finished
,This
>:RawOptionalReducerWithoutFinish
<Value
,This
> &object
A reducer that reduces by combining pairs of values using RawOptionalReducerWithoutFinish.add and then transforming the final value using RawOptionalReducerWithFinish.finish.
Type declaration
finish()
finish: (
this
,acc
) =>Finished
Parameters
this
This
acc
Value
Returns
Finished
Type Parameters
• Value = unknown
• Finished = Value
• This = unknown
Example
import { or, pipe, reduce } from 'lfi'
console.log(
pipe(
[1, 2, 3, 4],
reduce(
// This is a `RawOptionalReducerWithFinish`
{
add: (number1, number2) => number1 + number2,
finish: sum => `The sum is ${sum}`,
},
),
or(() => `There are no numbers`),
),
)
//=> The sum is 10
Since
v2.0.0