Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
571 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /**
|
---|
| 2 | * The base implementation of `_.clamp` which doesn't coerce arguments.
|
---|
| 3 | *
|
---|
| 4 | * @private
|
---|
| 5 | * @param {number} number The number to clamp.
|
---|
| 6 | * @param {number} [lower] The lower bound.
|
---|
| 7 | * @param {number} upper The upper bound.
|
---|
| 8 | * @returns {number} Returns the clamped number.
|
---|
| 9 | */
|
---|
| 10 | function baseClamp(number, lower, upper) {
|
---|
| 11 | if (number === number) {
|
---|
| 12 | if (upper !== undefined) {
|
---|
| 13 | number = number <= upper ? number : upper;
|
---|
| 14 | }
|
---|
| 15 | if (lower !== undefined) {
|
---|
| 16 | number = number >= lower ? number : lower;
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 | return number;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | module.exports = baseClamp;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.