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

x/rimbu/common/async-reducer.ts>AsyncReducer.combineObj

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

Returns an AsyncReducer that combines multiple input reducers by providing input values to all of them and collecting the outputs in the shape of the given object.

Examples

Example 1

const red = AsyncReducer.combineObj({
  theSum: Reducer.sum,
  theAverage: Reducer.average
});

await AsyncStream.from(Stream.range({ amount: 9 }))
  .reduce(red));
// => { theSum: 36, theAverage: 4 }

Type Parameters

T
R extends { readonly [key: string]: unknown; }

Parameters

reducerObj: readonly [K in keyof R]: AsyncReducer<T, R[K]> & Record<string, AsyncReducer<T, unknown>>
  • an object of keys, and reducers corresponding to those keys