Hyperlinkv0.8.0-beta.28

HashMap

HashMap.mutateconsteffect/HashMap.ts:773
<K, V>(f: (self: HashMap<K, V>) => void): (
  self: HashMap<K, V>
) => HashMap<K, V>
<K, V>(self: HashMap<K, V>, f: (self: HashMap<K, V>) => void): HashMap<
  K,
  V
>

Runs a batch of updates against a transient mutable copy of the HashMap and returns the finalized immutable result.

Details

The callback may call mutation-oriented helpers such as set and remove on the transient map.

Example (Applying batched mutations)

import { HashMap } from "effect"

const map1 = HashMap.make(["a", 1])
const map2 = HashMap.mutate(map1, (mutable) => {
  HashMap.set(mutable, "b", 2)
  HashMap.set(mutable, "c", 3)
})
// Returns a new HashMap with mutations applied
mutations
Source effect/HashMap.ts:7734 lines
export const mutate: {
  <K, V>(f: (self: HashMap<K, V>) => void): (self: HashMap<K, V>) => HashMap<K, V>
  <K, V>(self: HashMap<K, V>, f: (self: HashMap<K, V>) => void): HashMap<K, V>
} = internal.mutate