Read OSS

unjs/defu

3 articles

Prerequisites

01

Defu: Architecture and API Design of a 100-Line Deep Defaults Library

A high-level tour of defu's project structure, public API surface, factory pattern, dual CJS/ESM publishing, and CI pipeline.

02

Inside Defu's Recursive Merge: Algorithm, Security, and Extensibility

A deep dive into _defu's ~40-line recursive merge algorithm: decision branches, prototype pollution prevention, the isPlainObject guard, and the Strategy Pattern merger hook.

03

Type-Level Deep Merge: How Defu Models Recursive Object Merging in TypeScript

Dissecting defu's ~112-line type system: variadic tuple recursion, nullish-aware key merging, and the Merge dispatch chain that mirrors every runtime decision at the type level.