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CAAC","file":"tool.js","sourcesContent":["/*\n * @Author: shiyanzhang\n * @Date: 2021-08-26 11:36:23\n * @Description:\n * @FilePath: /tdesign-miniprogram/src/slider/tool.ts\n */\n\n/**\n * 处理单个number的超限和异常\n * @param {any} value\n * @param {number} min\n * @param {number} max\n * @return {number}\n */\nexport const trimSingleValue = (value: any, min: number, max: number): number => {\n if (typeof value !== 'number') {\n return min;\n }\n if (value < min) {\n return min;\n }\n\n if (value > max) {\n return max;\n }\n\n return value;\n};\n\n/**\n * 处理超限和异常value\n * @param value\n * @param props\n * @returns\n */\nexport const trimValue = (value: number | number[], props): number | number[] => {\n const { min, max, range } = props;\n\n if (range && Array.isArray(value)) {\n value[0] = trimSingleValue(value[0], min, max);\n value[1] = trimSingleValue(value[1], min, max);\n\n return value[0] <= value[1] ? value : [value[1], value[0]];\n }\n\n if (range) {\n return [min, max];\n }\n\n if (!range) {\n return trimSingleValue(value, min, max);\n }\n};\n"]}
|