@augment-vir/common
Version:
A collection of augments, helpers types, functions, and classes for any JavaScript environment.
20 lines (19 loc) • 676 B
TypeScript
import { MinMax } from '@augment-vir/core';
/**
* 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).
*
* @category Number
* @category Package : @augment-vir/common
* @example
*
* ```ts
* import {wrapNumber} from '@augment-vir/common';
*
* wrapNumber({min: 0, max: 100, value: 101}); // 0
* wrapNumber({min: 0, max: 100, value: -1}); // 100
* ```
*
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare function wrapNumber(value: number, minMax: Readonly<MinMax>): number;