Recursively merges a patch object into a base object.
This function performs a deep merge for nested records. Arrays and primitive types in the patch object will overwrite the corresponding values in base.
patch
base
The type of the base record.
The initial record object.
The partial record containing updates. If null or undefined, base is returned as-is.
null
undefined
A new object containing the merged properties.
const base = { a: 1, b: { c: 2 } };const patch = { b: { d: 3 }, e: 4 };const result = recursiveMerge(base, patch);// { a: 1, b: { c: 2, d: 3 }, e: 4 } Copy
const base = { a: 1, b: { c: 2 } };const patch = { b: { d: 3 }, e: 4 };const result = recursiveMerge(base, patch);// { a: 1, b: { c: 2, d: 3 }, e: 4 }
Recursively merges a patch object into a base object.
This function performs a deep merge for nested records. Arrays and primitive types in the
patchobject will overwrite the corresponding values inbase.