gradum-kit - v0.1.0
    Preparing search index...

    Function mod

    • Function

      mod

      Parameters

      • value: number

        The value to wrap.

      • modValue: number

        The modulus. Must be non-zero.

      Returns number

      The wrapped value, always in [0, modValue).

      Wrap a number into [0, modValue), so negative inputs come back positive — unlike the % operator, which keeps the sign of its left operand. Use it to cycle an index around a list.

      If modValue is 0, since no value can be wrapped into an empty range. Guard the call when the modulus comes from a length that may be zero.