Merges a source object into a target one recursively and returns the target object.
- Source:
Methods
(static) deepMerge(source, target) → {object.<*, *>}
- Source:
Example
import { deepMerge } from '@untemps/utils/object/deepMerge'
const source = { foo: 1, bar: { gag: [1, 2, 3], pol: { mur: 'mur' } } }
const target = { foo: 2, zaz: { juv: 1 }, bar: { gag: 'gag' } }
deepMerge(source, target) // { foo: 1, zaz: { juv: 1 }, bar: { gag: [1, 2, 3], pol: { mur: 'mur' } } }
Parameters:
Name | Type | Description |
---|---|---|
source |
object.<*, *> | The object to merge into the target. |
target |
object.<*, *> | The target object where source will be merged. |
Returns:
The target object containing both source and target keys with source precedence.
- Type
- object.<*, *>