Package: effect
Module: Record
Applies a function to the element at the specified key safely, creating a new record,
or return Option.none() if the key doesn’t exist.
Example (Modifying a value at a key)
import { Record } from "effect"
const f = (x: number) => x * 2
const input: Record<string, number> = { a: 3 }
Record.modify(input, "a", f) // Option.some({ a: 6 })
Record.modify(input, "b", f) // Option.none()
Signature
declare const modify: { <K extends string | symbol, A, B>(key: NoInfer<K>, f: (a: A) => B): (self: ReadonlyRecord<K, A>) => Option.Option<Record<K, A | B>>; <K extends string | symbol, A, B>(self: ReadonlyRecord<K, A>, key: NoInfer<K>, f: (a: A) => B): Option.Option<Record<K, A | B>>; }
Since v2.0.0