Skip to content

Function.fold

github-actions[bot] edited this page Nov 18, 2026 · 4 revisions

umt / fold

Function: fold()

fold<T, U>(reducer, initialValue): (array) => U

Defined in: Pipe/fold.ts:10

Creates a pipe operator that reduces an array to a single value

Type Parameters

T

T

U

U

Parameters

reducer

(accumulator, value, index) => U

The function that combines the accumulator with each element

initialValue

U

The initial accumulator value

Returns

An operator that returns the accumulated value

(array) => U

Example

pipe([1, 2, 3], fold((sum, x) => sum + x, 0)); // 6

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally