Introduction to Zuord
Zuord (from the German word for "assign" or "map") is a TypeScript-first utility library for transforming structured objects, offering fully synchronized type inference β at both runtime and compile time.
Harmony Between Runtime and Type Transformationsβ
Zuord provides a fully synchronized API for both runtime behavior and compile-time types.
Each transformation is available in two aligned forms:
zuord
: Runtime functions βintegrate
,merge
,evolve
,pick
,omit
, etc.Zuord
: Type-level utilities βIntegrate
,Merge
,Evolve
,Pick
,Omit
, etc.
Top-tier compiler experience with zero runtime overheadβ
Unlike other libraries, Zuord aims to provide a compiler experience that perfectly aligns with runtime behavior, without any runtime overhead.
Smarter Manipulations & Inferencesβ
Zuord delivers smarter and more precise runtime manipulations and compile-time type inferences compared to native implementations and popular alternatives. Hereβs why Zuord stands out:
-
Recursive by Nature
Zuord operates recursively, applying deep operations across all levels by default:- Runtime Example
- Type Inference
const foo = { a: { b: { x: "zuord", y: "is" } } };
const bar = { a: { b: { z: "cool" as const } } };
const out = zuord.merge([foo, bar]);
// Value: { a: { b: { x: "zuord", y: "is", z: "cool" } } }
// Type: { a: { b: { x: string, y: string, z: "cool" } } }type Foo = { a: { b: { x: "zuord", y: "is" } } };
type Bar = { a: { b: { z: "cool" } } };
type Out = Zuord.Merge<[Foo, Bar]>;
// Value: (not available β this is a type-only evaluation)
// Type: { a: { b: { x: "zuord", y: "is", z: "cool" } } } -
Special Behaviors
Zuord includes built-in special behaviors, designed to match real-world use cases.For example, the merge operation concatenates arrays by default:
const foo = { h: ["zuord", "is"], l: [2, [2, 2]] };
const bar = { h: ["cool"], l: [4, [5, 6]] };
const out = zuord.merge([foo, bar]);
// Zuord behavior: { h: ["zuord", "is", "cool"], l: [2, [2, 2], 4, [5, 6]] }
// Other libraries: { h: ["cool"], l: [4, [5, 6]] } (overridden)Explore all Special Behaviors in detail.
-
Configurable Usage
Zuord enables you to override default behaviors according to your specific use cases.- Runtime Example
- Type Inference
const foo = { a: { b: { x: "zuord", y: "is" } }, l: [2, [2, 2]] };
const bar = { a: { b: { z: "cool" as const } }, l: [4, [5, 6]] };
const options: Zuord.MergeOptions = { shallow: true, concat : false }
const out = zuord.merge([foo, bar], options);
// Value: { a: { b: { z: "cool" } }, l: [4, [5, 6]] }
// Type: { a: { b: { z: "cool" } }, l: (number | number[])[] }type Foo = { a: { b: { x: "zuord", y: "is" } }, l: [2, [2, 2]] };
type Bar = { a: { b: { z: "cool" } }, l: [4, [5, 6]] };
type Options = Zuord.MergeOptionsOf<{ shallow: true, concat : false }>
type Out = Zuord.Merge<[Foo, Bar], Options>;
// Value: (not available β this is a type-only evaluation)
// Type: { a: { b: { z: "cool" } }, l: (4 | 2 | [2, 2] | [5, 6])[] }