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).

    Parameters

    • value: number
    • minMax: Readonly<MinMax>

    Returns number

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

    wrapNumber({min: 0, max: 100, value: 101}); // 0
    wrapNumber({min: 0, max: 100, value: -1}); // 100