Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1x 1x 3x 3x 2x 1x 2x 2x 1x 1x | import { purry } from './purry';
/**
* Clamp the given value within the inclusive min and max bounds.
* @param value the number
* @param limits the bounds limits
* @signature
* R.clamp(value, { min, max });
* @example
* clamp(10, { min: 20 }) // => 20
* clamp(10, { max: 5 }) // => 5
* clamp(10, { max: 20, min: 5 }) // => 10
* @data_first
* @category Number
*/
export function clamp(
value: number,
limits: { min?: number; max?: number }
): number;
/**
* Clamp the given value within the inclusive min and max bounds.
* @param value the number
* @param limits the bounds limits
* @signature
* R.clamp({ min, max })(value);
* @example
* clamp({ min: 20 })(10) // => 20
* clamp({ max: 5 })(10) // => 5
* clamp({ max: 20, min: 5 })(10) // => 10
* @data_last
* @category Number
*/
export function clamp(limits: {
min?: number;
max?: number;
}): (value: number) => number;
export function clamp() {
return purry(_clamp, arguments);
}
function _clamp(value: number, limits: { min?: number; max?: number }) {
if (limits.min != null) {
if (limits.min > value) {
return limits.min;
}
}
Eif (limits.max != null) {
if (limits.max < value) {
return limits.max;
}
}
return value;
}
|