(obj: Record<string, any>, dottedPath: string, value: unknown)
| 44 | } |
| 45 | |
| 46 | /** Set a dotted path on a plain object, creating intermediate objects. PURE. */ |
| 47 | export function setDeep(obj: Record<string, any>, dottedPath: string, value: unknown): void { |
| 48 | const parts = dottedPath.split('.'); |
| 49 | let cur = obj; |
| 50 | for (let i = 0; i < parts.length - 1; i++) { |
| 51 | const k = parts[i]!; |
| 52 | if (typeof cur[k] !== 'object' || cur[k] === null) cur[k] = {}; |
| 53 | cur = cur[k]; |
| 54 | } |
| 55 | cur[parts[parts.length - 1]!] = value; |
| 56 | } |
| 57 | |
| 58 | /** Read a dotted path from a plain object (for rendering current values). PURE. */ |
no outgoing calls
no test coverage detected