Skip to main content
Module

x/rimbu/mod.ts>AsyncReducer.first

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

Returns an AsyncReducer that remembers the first input value.

Examples

Example 1

await AsyncStream.from(Stream.range{ amount: 10 })).reduce(AsyncReducer.first())
// => 0

type

{ <T>(): AsyncReducer<T, T | undefined>; <T, O>(otherwise: AsyncOptLazy<O>): AsyncReducer<T, T | O>; }