Options
All
  • Public
  • Public/Protected
  • All
Menu

Module mergeWith

Index

References

Functions Object

References

Renames and re-exports __type

Object Functions

  • mergeWith(object: any, ...sourcesOrCustomizer: any[]): any
  • This method is like merge except that it accepts customizer which is invoked to produce the merged values of the destination and source properties. If customizer returns undefined, merging is handled by the method instead. The customizer is invoked with six arguments: (objValue, srcValue, key, object, source, stack).

    Note: This method mutates object.

    since

    5.12.0

    example
    function customizer(objValue, srcValue) {
    if (Array.isArray(objValue)) {
    return objValue.concat(srcValue)
    }
    }

    const object = { 'a': [1], 'b': [2] }
    const other = { 'a': [3], 'b': [4] }

    mergeWith(object, other, customizer)
    // => { 'a': [1, 3], 'b': [2, 4] }

    Parameters

    • object: any

      The destination object.

    • Rest ...sourcesOrCustomizer: any[]

      The source objects. The function to customize assigned values.

    Returns any

    Returns object.