Package: effect
Module: Optic
Iso that converts a Record<string, A> to an array of
[key, value] entries and back.
When to use
Use when you want to traverse or manipulate record entries as an array (e.g.
with .forEach()).
Details
get uses Object.entries.set uses Object.fromEntries.Record<string, A>.Example (Traversing record values)
import { Optic, Schema } from "effect"
const _positiveValues = Optic.entries<number>()
.forEach((entry) => entry.key(1).check(Schema.isGreaterThan(0)))
const inc = _positiveValues.modifyAll((n) => n + 1)
console.log(inc({ a: 0, b: 3, c: -1 }))
// Output: { a: 0, b: 4, c: -1 }
See
Iso — the type this function returnsid — identity isoSignature
declare const entries: <A>() => Iso<Record<string, A>, ReadonlyArray<readonly [string, A]>>
Since v4.0.0