construct
@guoba-ai/utils / object / construct
Function: construct()
function construct<T>(obj): T;Defined in: object.ts:473
Build a nested object from a flat object with dot-path keys (reverse of crush).
Parameters
obj
Record<string, unknown>
A flat object with dot-path keys
Returns
T
A deeply nested object
Example
construct({ 'a.b': 1, 'a.c.d': 2 })
// { a: { b: 1, c: { d: 2 } } }
construct({ x: 1, y: 2 }) // { x: 1, y: 2 }
construct(crush({ a: { b: 1 } })) // { a: { b: 1 } }
construct({ '__proto__.polluted': 1 }) // throws TypeError