|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
502 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { toNumber } from '../util/toNumber.mjs';
|
|---|
| 2 |
|
|---|
| 3 | function clamp(value, bound1, bound2) {
|
|---|
| 4 | if (bound2 === undefined) {
|
|---|
| 5 | bound2 = bound1;
|
|---|
| 6 | bound1 = undefined;
|
|---|
| 7 | }
|
|---|
| 8 | if (bound2 !== undefined) {
|
|---|
| 9 | bound2 = toNumber(bound2);
|
|---|
| 10 | value = Math.min(value, Number.isNaN(bound2) ? 0 : bound2);
|
|---|
| 11 | }
|
|---|
| 12 | if (bound1 !== undefined) {
|
|---|
| 13 | bound1 = toNumber(bound1);
|
|---|
| 14 | value = Math.max(value, Number.isNaN(bound1) ? 0 : bound1);
|
|---|
| 15 | }
|
|---|
| 16 | return value;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | export { clamp };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.