/**
 * @since Last modified: 2024-01-17 14:47:33
 * @function clampVal
 * @description Limit the value to a range.
 * @param {object} options - Parameters of clampVal.
 * @param  {string|number} options.value - The value passed in.
 * @param  {""|null|string|number} [options.max=100] - The max value.
 * @param  {""|null|string|number} [options.min=0] - The min value.
 * @returns  {number}  - The new value.
 * @see {@link https://codepen.io/axui/pen/gOEgWPb|demo @ codepen}
 * @example
 * ax.clampVal({val:2000});
 * <!--return 100-->
 */
'use strict';
import toNumber from "./toNumber";
const clampVal = ({ val = 0, min = 0, max = 100 }) => {
    let tmpVal = toNumber(val), tmpMin = toNumber(min), tmpMax = toNumber(max);
    return (!['', null, undefined].includes(min) && tmpVal < tmpMin) ? tmpMin :
        (!['', null, undefined].includes(max) && tmpVal > tmpMax) ? tmpMax : tmpVal;
};
export default clampVal;
