How unjs/defu works
defu is a small TypeScript library for recursively applying defaults to objects. The main workflow accepts a destination and one or more defaults, then returns a merged object; custom merger hooks and function-based variants alter how individual values are handled. Runtime merging and its plain-object check are visible in the sampled source. The README documents the public variants, while the type model is a separate compile-time capability. No external services or persistent state are involved.
Main entry points: defu.ts Merge APIs · _utils.ts Plain-object check · types.ts Merge type model
Components 4
Other components
- Library consumer
- Merge APIs
src/defu.ts - Plain-object check
src/_utils.ts - Merge type model
src/types.ts
Connections 3
- Library consumer → Merge APIs: calls
README.md - Merge APIs → Plain-object check: checks objects
src/defu.ts - Merge APIs → Merge type model: exports types
src/defu.ts