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

x/rimbu/common/reducer.ts>Reducer.toJSObject

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

Returns a Reducer 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

console.log(Stream.of(['a', 1], ['b', true]).reduce(Reducer.toJSObject()))
// { a: 1, b: true }

Type Parameters

K extends string | number | symbol
V

Returns

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