Package: effect
Module: Struct
Creates a new struct containing only the specified keys.
When to use
Use to narrow a struct down to a subset of its properties.
Gotchas
Keys not present in the struct are silently ignored.
Example (Selecting specific properties)
import { pipe, Struct } from "effect"
const user = { name: "Alice", age: 30, admin: true }
const nameAndAge = pipe(user, Struct.pick(["name", "age"]))
console.log(nameAndAge) // { name: "Alice", age: 30 }
See
omit – the inverse (exclude keys instead)get – extract a single valueSignature
declare const pick: { <S extends object, const Keys extends ReadonlyArray<keyof S>>(keys: Keys): (self: S) => Simplify<Pick<S, Keys[number]>>; <S extends object, const Keys extends ReadonlyArray<keyof S>>(self: S, keys: Keys): Simplify<Pick<S, Keys[number]>>; }
Since v2.0.0