Skip to main content
Module

x/rimbu/mod.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.14.0/mod.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>>