UNPKG
froebel
Version:
latest (0.23.2)
0.23.2
0.23.1
0.23.0
0.22.0
0.21.3
0.21.2
0.21.1
0.21.0
0.20.0
0.19.0
0.18.0
0.17.0
0.16.1
0.15.0
0.14.4
0.14.3
0.14.1
TypeScript utility library
github.com/MathisBullinger/froebel
MathisBullinger/froebel
froebel
/
clamp.mjs
7 lines
(6 loc)
•
202 B
JavaScript
View Raw
1
2
3
4
5
6
7
/** Clamp `num` between `
min
`
and
`
max
` inclusively. */ const clamp = (
min
, num,
max
) => {
if
(
min
>
max
) [
min
,
max
] = [
max
,
min
];
return
Math.
max
(Math.
min
(num,
max
),
min
); }; export default clamp;