tool.d.ts.map 1.3 KB

1
  1. {"version":3,"sources":["../src/slider/tool.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAAW,GAAG,OAAO,MAAM,OAAO,MAAM,KAAG,MAatE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,UAAW,MAAM,GAAG,MAAM,EAAE,iBAAU,MAAM,GAAG,MAAM,EAiB1E,CAAC","file":"tool.d.ts","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"]}