• A function to help override a property in a nested object Example usage

    const baseObject = {
    level1: {
    level2: {
    level3: {
    value: 42,
    },
    },
    },
    };

    const updatedObject = overrideProperty(
    baseObject,
    ['level1', 'level2', 'level3', 'value'],
    99
    );

    updatedObject.level1.level2.level3.value === 99

    Parameters

    • baseObject: NestedObject

      A base context object of undefined depth.

    • propertyPath: string[]

      An array of strings of undefined length, representing from left to right the property you want to override by accessing each preceding node in the object.

    • overrideValue: unknown

      The value that will override the rightmost string in propertyPath.

    Returns NestedObject

Generated using TypeDoc