Skip to main content
Module

x/rimbu/mod.ts>AsyncReducer.createOutput

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

Returns an AsyncReducer of which the state and output types are the same.

Type Parameters

I
optional
O = I

Parameters

  • the optionally lazy and/or promised initial state value
next: (
current: O,
next: I,
index: number,
halt: () => void,
) => MaybePromise<O>
  • returns (potentially asynchronously) the next state value based on the given inputs:
  • current: the current state
  • next: the current input value
  • index: the input index value
  • halt: function that, when called, ensures no more elements are passed to the reducer
optional
stateToResult: (state: O) => MaybePromise<O>
  • a potentially asynchronous function that converts the current state to an output value
optional
onClose: (state: O, error?: unknown) => MaybePromise<void>
  • (optional) a function that will be called when the reducer will no longer receive values