source: node_modules/es-toolkit/dist/math/clamp.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[a762898]1/**
2 * Clamps a number within the inclusive upper bound.
3 *
4 * This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound.
5 * If only one bound is provided, it returns the minimum of the value and the bound.
6 *
7 * @param {number} value - The number to clamp.
8 * @param {number} maximum - The maximum bound to clamp the number.
9 * @returns {number} The clamped number within the specified upper bound.
10 *
11 * @example
12 * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5
13 */
14declare function clamp(value: number, maximum: number): number;
15/**
16 * Clamps a number within the inclusive lower and upper bounds.
17 *
18 * This function takes a number and two bounds, and returns the number clamped within the specified bounds.
19 *
20 * @param {number} value - The number to clamp.
21 * @param {number} minimum - The minimum bound to clamp the number.
22 * @param {number} maximum - The maximum bound to clamp the number.
23 * @returns {number} The clamped number within the specified bounds.
24 *
25 * @example
26 * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15
27 * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5
28 * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15
29 */
30declare function clamp(value: number, minimum: number, maximum: number): number;
31
32export { clamp };
Note: See TracBrowser for help on using the repository browser.