UNPKG

data-collectors

Version:

A collection of composable reduction operations for arbitrary streams of values

11 lines (9 loc) 292 B
import { Collector } from "../collector"; export function last<T> () : Collector<T, { value: T }, T> { return Collector.of( () => ( { value: null } ), ( state, item ) => state.value = item, ( _, stateB ) => stateB, state => state.value ); }