effect-io-ai

Package: effect
Module: Struct

Struct.get

Retrieves the value at key from a struct.

When to use

Use to extract a single property from a struct in a pipeline.

Details

The return type is narrowed to S[K].

Example (Extracting a property in a pipeline)

import { pipe, Struct } from "effect"

const name = pipe({ name: "Alice", age: 30 }, Struct.get("name"))
console.log(name) // "Alice"

See

Signature

declare const get: { <S extends object, const K extends keyof S>(key: K): (self: S) => S[K]; <S extends object, const K extends keyof S>(self: S, key: K): S[K]; }

Source

Since v2.0.0