Package: effect
Module: Struct
Applies a Lambda transformation to all keys except the specified
ones; the excluded keys are copied unchanged.
When to use
Use when most keys should be transformed but a few should be preserved.
Example (Wrapping all values except one in arrays)
import { pipe, Struct } from "effect"
interface AsArray extends Struct.Lambda {
<A>(self: A): Array<A>
readonly "~lambda.out": Array<this["~lambda.in"]>
}
const asArray = Struct.lambda<AsArray>((a) => [a])
const result = pipe(
{ x: 1, y: 2, z: 3 },
Struct.mapOmit(["y"], asArray)
)
console.log(result) // { x: [1], y: 2, z: [3] }
See
map – apply a lambda to all keysmapPick – apply a lambda only to selected keysSignature
declare const mapOmit: { <S extends object, const Keys extends ReadonlyArray<keyof S>, L extends Lambda>(keys: Keys, lambda: L): (self: S) => { [K in keyof S]: K extends Keys[number] ? S[K] : Apply<L, S[K]>; }; <S extends object, const Keys extends ReadonlyArray<keyof S>, L extends Lambda>(self: S, keys: Keys, lambda: L): { [K in keyof S]: K extends Keys[number] ? S[K] : Apply<L, S[K]>; }; }
Since v4.0.0