Skip to main content

Type Alias: RawReducerWithoutFinish<Value, Acc, This>

RawReducerWithoutFinish<Value, Acc, This>: object

A reducer that reduces by creating an initial accumulator using RawReducerWithoutFinish.create and then adding values to the accumulator values using RawReducerWithoutFinish.add.

Type Parameters

Value = unknown

Acc = Value

This = unknown

Type declaration

add()

add: (this, acc, value) => Acc

Parameters

this

This

acc

Acc

value

Value

Returns

Acc

create()

create: (this) => Acc

Parameters

this

This

Returns

Acc

Example

import { pipe, reduce } from 'lfi'

console.log(
pipe(
[1, 2, 3, 4],
reduce(
// This is a `RawReducerWithoutFinish`
{
create: () => 0,
add: (number1, number2) => number1 + number2,
},
),
),
)
//=> 10
Playground

Since

v2.0.0

Defined in

reducers.d.ts:163