Hyperlinkv0.8.0-beta.28

MutableHashMap

MutableHashMap.forEachconsteffect/MutableHashMap.ts:840
<K, V>(f: (value: V, key: K) => void): (
  self: MutableHashMap<K, V>
) => void
<K, V>(self: MutableHashMap<K, V>, f: (value: V, key: K) => void): void

Runs a callback for each key-value pair in the MutableHashMap.

When to use

Use to run a synchronous side-effecting callback for every key-value pair in an existing mutable map.

Details

Iteration follows the backing map's order. The callback receives the value first and the key second, matching Map.prototype.forEach.

traversingkeysvalues
export const forEach: {
  <K, V>(f: (value: V, key: K) => void): (self: MutableHashMap<K, V>) => void
  <K, V>(self: MutableHashMap<K, V>, f: (value: V, key: K) => void): void
} = dual(2, <K, V>(self: MutableHashMap<K, V>, f: (value: V, key: K) => void) => {
  self.backing.forEach(f)
})