effect-io-ai

Package: effect
Module: HashMap

HashMap.reduce

Reduces the specified state over the entries of the HashMap.

Example (Reducing values)

import { HashMap } from "effect"

const map = HashMap.make(["a", 1], ["b", 2], ["c", 3])
const sum = HashMap.reduce(map, 0, (acc, value) => acc + value)

console.log(sum) // 6

Signature

declare const reduce: { <Z, V, K>(zero: Z, f: (accumulator: Z, value: V, key: K) => Z): (self: HashMap<K, V>) => Z; <K, V, Z>(self: HashMap<K, V>, zero: Z, f: (accumulator: Z, value: V, key: K) => Z): Z; }

Source

Since v2.0.0