Skip to content

mergeObjects ​

Function that, given two objects version, merges them into a single one. Via an optional parameter forceUndefinedValue you can define how undefined values are treated.

Types ​

MergeObjectsProps ​

  • @template T - The target object type.

Parameters accepted by mergeObjects.

PropertyTypeRequiredDescription
oldObjT✓The base object whose properties are used as defaults. Properties present in newObj override those in oldObj.
newObjRecursivePartial<T>✓A partial object containing the properties to merge into oldObj. Accepts a {@link RecursivePartial} so deeply nested properties can be partially overridden without supplying the full subtree.
forceUndefinedValuebooleanWhen true, properties in newObj whose value is explicitly undefined are written into the result, overriding the corresponding oldObj value with undefined. When false or omitted, undefined values in newObj are ignored and the oldObj value is preserved.

Released under the MIT License.