Hyperlinkv0.8.0-beta.28

HashMap

HashMap.modifyconsteffect/HashMap.ts:883
<K, V>(key: K, f: (v: V) => V): (self: HashMap<K, V>) => HashMap<K, V>
<K, V>(self: HashMap<K, V>, key: K, f: (v: V) => V): HashMap<K, V>

Updates the value of the specified key within the HashMap if it exists.

Example (Modifying existing values)

import { HashMap } from "effect"

const map1 = HashMap.make(["a", 1], ["b", 2])
const map2 = HashMap.modify(map1, "a", (value) => value * 3)

console.log(HashMap.get(map2, "a")) // Option.some(3)
console.log(HashMap.get(map2, "b")) // Option.some(2)
transforming
Source effect/HashMap.ts:8834 lines
export const modify: {
  <K, V>(key: K, f: (v: V) => V): (self: HashMap<K, V>) => HashMap<K, V>
  <K, V>(self: HashMap<K, V>, key: K, f: (v: V) => V): HashMap<K, V>
} = internal.modify