Returns a valid index within the given maximum index. Out of bound index loops back to the first valid index.

  • Parameters

    • index: number

      The index to validate.

    • OptionalmaxIndex: number

      The maximum index. If not provided or 0, returns 0.

    Returns number

    The valid index.