Hyperlinkv0.8.0-beta.28

HashMap

HashMap.forEachconsteffect/HashMap.ts:1066
<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

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]]
traversing
export 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
} = internal.forEach