Function updateWith

  • This method is like update except that it accepts customizer which is invoked to produce the objects of path. If customizer returns undefined path creation is handled by the method instead. The customizer is invoked with three arguments: (nsValue, key, nsObject).

    Note: This method mutates object.

    Type Parameters

    • T extends object

    Parameters

    • object: T

      The object to modify.

    • path: PropertyPath

      The path of the property to set.

    • updater: ((value: any) => any)

      The function to produce the updated value.

        • (value): any
        • Parameters

          • value: any

          Returns any

    • Optionalcustomizer: ((value: any, key: string, nested: any) => any)

      The function to customize assigned values.

        • (value, key, nested): any
        • Parameters

          • value: any
          • key: string
          • nested: any

          Returns any

    Returns any

    Returns object.

    4.6.0

    const object = {}

    updateWith(object, '[0][1]', () => 'a', Object)
    // => { '0': { '1': 'a' } }