Skip to content

struct

struct<Fns>(fields): (value) => StructOutput<Fns>

Defined in: Composition/struct.ts:23

Builds an object by applying a record of field-level transformer functions to the input value.

The input type is inferred from the transformer parameters, so standalone struct({...}) works. Own string and symbol keys are processed; inherited fields are ignored.

Fns extends Record<PropertyKey, (value) => unknown>

Fns

(value) => StructOutput<Fns>

pipe(
  { name: "Alice", age: 25 },
  struct({
    name: u => u.name,
    isAdult: u => u.age >= 18
  })
); // { name: "Alice", isAdult: true }

struct<A, R>(fields): (value) => R

Defined in: Composition/struct.ts:26

Builds an object by applying a record of field-level transformer functions to the input value.

The input type is inferred from the transformer parameters, so standalone struct({...}) works. Own string and symbol keys are processed; inherited fields are ignored.

A

R extends object

{ [K in string | number | symbol]: (value: A) => R[K] }

(value) => R

pipe(
  { name: "Alice", age: 25 },
  struct({
    name: u => u.name,
    isAdult: u => u.age >= 18
  })
); // { name: "Alice", isAdult: true }