source: node_modules/es-toolkit/dist/compat/math/clamp.js@ ba17441

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

Added visualizations

  • Property mode set to 100644
File size: 614 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const toNumber = require('../util/toNumber.js');
6
7function clamp(value, bound1, bound2) {
8 if (bound2 === undefined) {
9 bound2 = bound1;
10 bound1 = undefined;
11 }
12 if (bound2 !== undefined) {
13 bound2 = toNumber.toNumber(bound2);
14 value = Math.min(value, Number.isNaN(bound2) ? 0 : bound2);
15 }
16 if (bound1 !== undefined) {
17 bound1 = toNumber.toNumber(bound1);
18 value = Math.max(value, Number.isNaN(bound1) ? 0 : bound1);
19 }
20 return value;
21}
22
23exports.clamp = clamp;
Note: See TracBrowser for help on using the repository browser.