toMerged es-toolkit
Returns a new object with the source object deeply merged into a copy of the target object.
Usage
toMerged(target, source)
Use toMerged when you want to deeply merge two objects but don't want to modify the original object. Unlike merge, this function does not modify the original target object and returns a new object.
undefined values do not overwrite existing values.
Parameters
targetT extends Record<PropertyKey, any>required
The target object to be merged. This object is not modified.
sourceS extends Record<PropertyKey, any>required
The source object to merge into the target object.
Returns
Returns a new object with the target and source objects merged.
Try It
::: sandpack
:::
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.