Hyperlinkv0.8.0-beta.28

HashMap

HashMap.reduceconsteffect/HashMap.ts:1088
<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

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
folding
export 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
} = internal.reduce
Referenced by 1 symbols