unflatten
Rebuilds a nested object from a single-level object whose keys are dot-notation paths. The inverse of flatten.
Uses set internally, so intermediate nodes are always created as
plain objects (never arrays — see flatten’s doc for why), and any
key segment equal to __proto__, constructor, or prototype is silently
rejected (same prototype-pollution guard as set).
Available since v3.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
obj | Record<string, unknown> | A single-level object with dot-notation keys |
Returns
Section titled “Returns”Record<string, unknown> — The rebuilt nested object
Examples
Section titled “Examples”Rebuild a nested object from dotted keys
Section titled “Rebuild a nested object from dotted keys”The inverse of flatten() — useful for parsing flat config sources (env vars, .ini files).
Multiple keys under the same parent are merged
Section titled “Multiple keys under the same parent are merged”Every dotted key contributes to the same nested structure.
