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

x/rimbu/mod.ts>AsyncReducer.last

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

Returns an AsyncReducer that remembers the last input value.

Examples

Example 1

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

type

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

Examples

Example 1

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

type

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