Package: effect
Module: Struct
Transforms keys of a struct selectively using per-key functions. Keys without a corresponding function are copied unchanged.
When to use
Use when you need computed key names, such as uppercasing or prefixing.
Details
Each transform function receives the key name and must return a new
PropertyKey.
Example (Renaming keys with functions)
import { pipe, Struct } from "effect"
const result = pipe(
{ name: "Alice", age: 30 },
Struct.evolveKeys({
name: (k) => k.toUpperCase()
})
)
console.log(result) // { NAME: "Alice", age: 30 }
See
renameKeys – rename keys with a static mappingevolve – transform values instead of keysevolveEntries – transform both keys and valuesSignature
declare const evolveKeys: { <S extends object, E extends KeyEvolver<S>>(e: E): (self: S) => KeyEvolved<S, E>; <S extends object, E extends KeyEvolver<S>>(self: S, e: E): KeyEvolved<S, E>; }
Since v4.0.0