augment-vir - v31.25.0
    Preparing search index...

    Function wrapNumber

    • If the given value is outside the given min/max bounds, instead of clamping the number (as the clamp function does), this function wraps the value around to the next bound (inclusive).

      If takeOverflow is set to true, then any excess after wrapping is continually iterated over and wrapped again, potentially resulting in wrapping through the min/max bounds multiple times.

      Parameters

      Returns number

      import {wrapNumber} from '@augment-vir/common';

      wrapNumber(101, {min: 0, max: 100}); // 0
      wrapNumber(-1, {min: 0, max: 100}); // 100
      wrapNumber(-7, {min: 0, max: 3, takeOverflow: true}); // 1
      wrapNumber(13, {min: 0, max: 3, takeOverflow: true}); // 1