* Copies a value for defaultsDeep: plain objects are copied recursively; * other values (including functions) are reused by reference. * * @param value - Value to copy * @returns Copy safe for further defaults merging
(value: unknown)
| 262 | * @returns Copy safe for further defaults merging |
| 263 | */ |
| 264 | function copyForDefaultsDeep(value: unknown): unknown { |
| 265 | if (!util.isPlainObject(value)) { |
| 266 | return value; |
| 267 | } |
| 268 | const out: Record<string, unknown> = {}; |
| 269 | for (const [key, val] of Object.entries(value)) { |
| 270 | out[key] = copyForDefaultsDeep(val); |
| 271 | } |
| 272 | return out; |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Fills `undefined` keys in a clone of `target` from `source` (recursive for plain objects). |