Function valueWithCompensation

Returns a value if it exists, otherwise executes a compensation function

  • Type Parameters

    • T

      The type of the value

    Parameters

    • params: {
          compensation: (() => T);
          value?: T;
      }

      Configuration object

      • compensation: (() => T)

        Function to execute if value doesn't exist

          • (): T
          • Returns T

      • Optionalvalue?: T

        The value to check (optional)

    Returns T

    The value if it exists, otherwise the result of the compensation function