effect-io-ai

Package: effect
Module: HashMap

HashMap.mutate

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

Signature

declare 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>; }

Source

Since v2.0.0