mergeObjects()
mergeObjects<
T,U>(object1,object2):T&U
Defined in: utils/object/mergeObjects.ts:18
Deeply merges two objects into a single object.
Type Parameters
T
T extends Record<string, unknown>
U
U extends Record<string, unknown>
Parameters
object1
T
The first object.
object2
U
The second object.
Returns
T & U
A new object that is the result of deeply merging object1 and object2.
Example
tsx
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 }, e: 4 };
const merged = mergeObjects(obj1, obj2);
console.log(merged); // { a: 1, b: { c: 2, d: 3 }, e: 4 }