Function mergeWithMutation

  • Execute a mutation function on the object and merge results.

    Parameters

    • target: any

      The target object to be merged with mutation.

    • options: MergeOptions

      Options for mutation, ommit keys and additional data.

    • parentKey: string = ''

      Internal tracking key for recursion.

    Returns Promise<any>

    The mutated and merged target object.

    await mergeWithMutation({ a: { b: 1 } }, { mutation: () => ({ c: 2 }) });
    // => { a: { b: 1, c: 2 } }