Function mergeObjectValuesBy

  • Merge the values of an array of objects using the specified merging function

    Example

    const obj = mergeObjectValuesBy([{ test: 'some' }, { test: null }], (a, b) => a || b)
    obj.test === 'some'

    Type Parameters

    • TKeys extends PropertyKey

    • TObj extends Record<TKeys, any>

    Parameters

    • objects: TObj[]

      the array of objects to merge

    • mergeFn: ((a, b) => TObj[TKeys])

      a function which defines the merging operation

        • (a, b): TObj[TKeys]
        • Parameters

          • a: TObj[TKeys]
          • b: TObj[TKeys]

          Returns TObj[TKeys]

    Returns TObj

Generated using TypeDoc