Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/mod.ts>AsyncReducer.fold

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function AsyncReducer.fold
import { AsyncReducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { fold } = AsyncReducer;

Returns an AsyncReducer that uses the given init and next values to fold the input values into result values.

Parameters

  • an (optionally lazy) initial result value
next: (
current: R,
value: T,
index: number,
halt: () => void,
) => MaybePromise<R>
  • a (potentially async) function taking the following arguments:
  • current - the current result value
  • value - the next input value
  • index: the input index value
  • halt: function that, when called, ensures no more elements are passed to the reducer