Function setValue

  • Sets the provided value on the target instance using the field name when the provided chk function returns true, the chk function will only be called if the new value is no equal to the original value.

    Type Parameters

    • T

    • K extends string | number | symbol

    Parameters

    • target: T

      The target object

    • field: K

      The key of the target

    • value: T[K]

      The value to set

    • Optional valChk: ((value) => boolean)

      [Optional] Callback to check the value that if supplied will be called check if the new value can be set

        • (value): boolean
        • Parameters

          • value: T[K]

          Returns boolean

    • Optional srcChk: ((value) => boolean)

      [Optional] Callback to check to original value that if supplied will be called if the new value should be set (if allowed)

        • (value): boolean
        • Parameters

          • value: T[K]

          Returns boolean

    Returns T[K]

    The existing or new value, depending what was set

Generated using TypeDoc