effect-io-ai

Package: effect
Module: HashMap

HashMap.forEach

Applies the specified function to the entries of the HashMap.

Example (Iterating with side effects)

import { HashMap } from "effect"

const map = HashMap.make(["a", 1], ["b", 2])
const collected: Array<[string, number]> = []

HashMap.forEach(map, (value, key) => {
  collected.push([key, value])
})

console.log(collected.sort()) // [["a", 1], ["b", 2]]

Signature

declare const forEach: { <V, K>(f: (value: V, key: K) => void): (self: HashMap<K, V>) => void; <V, K>(self: HashMap<K, V>, f: (value: V, key: K) => void): void; }

Source

Since v2.0.0