• Recursively merges two objects of compatible types. Properties of source are merged into corresponding properties of target. Properties with object values are recursively merged. Properties with primitive values are overridden by the values of source.

    Typeparam

    T - The type of the target object.

    Example

    const obj1 = { a: 1, b: { c: [2, 3], d: { e: 4 } } };
    const obj2 = { a: 2, b: { c: [4, 5], d: { f: 6 } } };
    merge(obj1, obj2)
    // => { a: 2, b: { c: [2, 3, 4, 5], d: { e: 4, f: 6 } } }

    Type Parameters

    • T extends Record<PropertyKey, any>

    Parameters

    • target: T

      The object to merge into.

    • source: T

      The object to merge from.

    Returns T

    A new object that is the merged result of target and source.

Generated using TypeDoc v0.24.7