Skip to main content
Module

x/rimbu/mod.ts>AsyncReducer.toJSObject

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

Returns an AsyncReducer that collects 2-tuples containing keys and values into a plain JS object, and returns a copy of that object when output is requested.

Examples

Example 1

await AsyncStream.of(['a', 1], ['b', true]).reduce(AsyncReducer.toJSObject()))
// { a: 1, b: true }

Type Parameters

K extends string | number | symbol
V

Returns

AsyncReducer<[K, V], Record<K, V>>