util-helpers 4.16.2 → 4.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/dist/util-helpers.js +1600 -4039
  2. package/dist/util-helpers.js.map +1 -1
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/ajax.js +50 -146
  6. package/esm/blobToDataURL.js +4 -34
  7. package/esm/bytesToSize.js +12 -37
  8. package/esm/calculateCursorPosition.js +30 -52
  9. package/esm/dataURLToBlob.js +14 -28
  10. package/esm/divide.js +24 -48
  11. package/esm/download.js +83 -164
  12. package/esm/fileReader.js +18 -64
  13. package/esm/filterTree.js +25 -55
  14. package/esm/findTreeNode.js +39 -67
  15. package/esm/findTreeNodes.js +35 -66
  16. package/esm/findTreeSelect.js +38 -74
  17. package/esm/formatBankCard.js +13 -43
  18. package/esm/formatMobile.js +17 -43
  19. package/esm/formatMoney.js +59 -139
  20. package/esm/index.js +55 -130
  21. package/esm/isBankCard.js +22 -57
  22. package/esm/isBusinessLicense.js +32 -78
  23. package/esm/isChinese.js +23 -66
  24. package/esm/isEmail.js +6 -21
  25. package/esm/isHMCard.js +5 -28
  26. package/esm/isIPv4.js +5 -22
  27. package/esm/isIPv6.js +5 -36
  28. package/esm/isIdCard.js +27 -66
  29. package/esm/isMobile.js +5 -20
  30. package/esm/isPassport.js +5 -22
  31. package/esm/isPassword.js +7 -48
  32. package/esm/isPostcode.js +5 -20
  33. package/esm/isPromiseLike.js +3 -18
  34. package/esm/isQQ.js +5 -20
  35. package/esm/isSocialCreditCode.js +28 -83
  36. package/esm/isSwiftCode.js +6 -25
  37. package/esm/isTWCard.js +11 -37
  38. package/esm/isTelephone.js +6 -27
  39. package/esm/isUrl.js +5 -44
  40. package/esm/isVehicle.js +5 -28
  41. package/esm/isWX.js +5 -20
  42. package/esm/listToTree.js +51 -120
  43. package/esm/minus.js +21 -39
  44. package/esm/normalizeString.js +8 -29
  45. package/esm/numberToChinese.js +96 -215
  46. package/esm/padZero.js +14 -36
  47. package/esm/parseIdCard.js +64 -129
  48. package/esm/plus.js +21 -39
  49. package/esm/randomString.js +13 -45
  50. package/esm/replaceChar.js +27 -77
  51. package/esm/round.js +14 -31
  52. package/esm/safeDate.js +12 -55
  53. package/esm/setDataURLPrefix.js +6 -29
  54. package/esm/strlen.js +14 -30
  55. package/esm/times.js +24 -42
  56. package/esm/transformFieldNames.js +37 -93
  57. package/esm/treeToList.js +25 -84
  58. package/esm/utils/config.js +4 -14
  59. package/esm/utils/constants.js +4 -4
  60. package/esm/utils/convertToString.js +4 -9
  61. package/esm/utils/devWarn.js +11 -11
  62. package/esm/utils/math.util.js +95 -181
  63. package/esm/utils/type/isBlob.js +4 -24
  64. package/esm/utils/type/isNaN.js +4 -19
  65. package/esm/utils/type/isNil.js +5 -13
  66. package/esm/utils/type/isNull.js +3 -18
  67. package/esm/utils/type/isNumber.js +4 -28
  68. package/esm/utils/type/isObject.js +4 -23
  69. package/esm/utils/type/isString.js +4 -19
  70. package/esm/utils/type/isSymbol.js +4 -19
  71. package/esm/utils/type/isType.js +3 -12
  72. package/esm/utils/type/isUndefined.js +3 -21
  73. package/esm/validatePassword.js +86 -237
  74. package/esm/waitTime.js +7 -26
  75. package/lib/ajax.js +51 -152
  76. package/lib/blobToDataURL.js +5 -40
  77. package/lib/bytesToSize.js +13 -43
  78. package/lib/calculateCursorPosition.js +32 -58
  79. package/lib/dataURLToBlob.js +15 -34
  80. package/lib/divide.js +26 -60
  81. package/lib/download.js +85 -169
  82. package/lib/fileReader.js +19 -70
  83. package/lib/filterTree.js +27 -66
  84. package/lib/findTreeNode.js +40 -77
  85. package/lib/findTreeNodes.js +36 -76
  86. package/lib/findTreeSelect.js +40 -82
  87. package/lib/formatBankCard.js +15 -50
  88. package/lib/formatMobile.js +19 -50
  89. package/lib/formatMoney.js +60 -150
  90. package/lib/index.js +117 -395
  91. package/lib/isBankCard.js +24 -64
  92. package/lib/isBusinessLicense.js +34 -85
  93. package/lib/isChinese.js +24 -73
  94. package/lib/isEmail.js +7 -27
  95. package/lib/isHMCard.js +7 -35
  96. package/lib/isIPv4.js +7 -29
  97. package/lib/isIPv6.js +7 -43
  98. package/lib/isIdCard.js +29 -73
  99. package/lib/isMobile.js +7 -27
  100. package/lib/isPassport.js +7 -29
  101. package/lib/isPassword.js +9 -55
  102. package/lib/isPostcode.js +7 -27
  103. package/lib/isPromiseLike.js +4 -24
  104. package/lib/isQQ.js +7 -27
  105. package/lib/isSocialCreditCode.js +30 -90
  106. package/lib/isSwiftCode.js +7 -32
  107. package/lib/isTWCard.js +13 -44
  108. package/lib/isTelephone.js +7 -33
  109. package/lib/isUrl.js +6 -49
  110. package/lib/isVehicle.js +7 -35
  111. package/lib/isWX.js +7 -27
  112. package/lib/listToTree.js +53 -131
  113. package/lib/minus.js +23 -51
  114. package/lib/normalizeString.js +10 -36
  115. package/lib/numberToChinese.js +98 -222
  116. package/lib/padZero.js +16 -43
  117. package/lib/parseIdCard.js +65 -138
  118. package/lib/plus.js +23 -51
  119. package/lib/randomString.js +14 -51
  120. package/lib/replaceChar.js +28 -83
  121. package/lib/round.js +15 -37
  122. package/lib/safeDate.js +13 -63
  123. package/lib/setDataURLPrefix.js +7 -35
  124. package/lib/strlen.js +16 -37
  125. package/lib/times.js +26 -53
  126. package/lib/transformFieldNames.js +38 -101
  127. package/lib/treeToList.js +27 -94
  128. package/lib/utils/config.js +6 -23
  129. package/lib/utils/constants.js +3 -11
  130. package/lib/utils/convertToString.js +6 -16
  131. package/lib/utils/devWarn.js +13 -17
  132. package/lib/utils/math.util.js +95 -185
  133. package/lib/utils/type/isBlob.js +6 -31
  134. package/lib/utils/type/isNaN.js +6 -26
  135. package/lib/utils/type/isNil.js +7 -20
  136. package/lib/utils/type/isNull.js +4 -24
  137. package/lib/utils/type/isNumber.js +6 -35
  138. package/lib/utils/type/isObject.js +5 -29
  139. package/lib/utils/type/isString.js +6 -26
  140. package/lib/utils/type/isSymbol.js +6 -26
  141. package/lib/utils/type/isType.js +4 -18
  142. package/lib/utils/type/isUndefined.js +4 -27
  143. package/lib/validatePassword.js +87 -244
  144. package/lib/waitTime.js +8 -32
  145. package/package.json +21 -25
  146. package/types/ajax.d.ts +38 -95
  147. package/types/blobToDataURL.d.ts +2 -2
  148. package/types/bytesToSize.d.ts +7 -6
  149. package/types/calculateCursorPosition.d.ts +10 -9
  150. package/types/dataURLToBlob.d.ts +5 -5
  151. package/types/divide.d.ts +2 -2
  152. package/types/download.d.ts +22 -38
  153. package/types/fileReader.d.ts +35 -2
  154. package/types/filterTree.d.ts +6 -7
  155. package/types/findTreeNode.d.ts +5 -7
  156. package/types/findTreeNodes.d.ts +5 -7
  157. package/types/findTreeSelect.d.ts +5 -7
  158. package/types/formatBankCard.d.ts +8 -5
  159. package/types/formatMobile.d.ts +7 -4
  160. package/types/formatMoney.d.ts +8 -7
  161. package/types/index.d.ts +125 -55
  162. package/types/isBankCard.d.ts +9 -8
  163. package/types/isBusinessLicense.d.ts +8 -5
  164. package/types/isChinese.d.ts +9 -8
  165. package/types/isEmail.d.ts +1 -1
  166. package/types/isHMCard.d.ts +2 -2
  167. package/types/isIPv4.d.ts +1 -1
  168. package/types/isIPv6.d.ts +1 -1
  169. package/types/isIdCard.d.ts +8 -7
  170. package/types/isMobile.d.ts +1 -1
  171. package/types/isPassport.d.ts +2 -2
  172. package/types/isPassword.d.ts +4 -7
  173. package/types/isPostcode.d.ts +1 -1
  174. package/types/isPromiseLike.d.ts +1 -1
  175. package/types/isQQ.d.ts +1 -1
  176. package/types/isSocialCreditCode.d.ts +8 -5
  177. package/types/isSwiftCode.d.ts +2 -2
  178. package/types/isTWCard.d.ts +6 -5
  179. package/types/isTelephone.d.ts +1 -1
  180. package/types/isUrl.d.ts +2 -2
  181. package/types/isVehicle.d.ts +2 -2
  182. package/types/isWX.d.ts +1 -1
  183. package/types/listToTree.d.ts +12 -12
  184. package/types/minus.d.ts +3 -2
  185. package/types/normalizeString.d.ts +2 -2
  186. package/types/numberToChinese.d.ts +13 -12
  187. package/types/padZero.d.ts +2 -2
  188. package/types/parseIdCard.d.ts +17 -56
  189. package/types/plus.d.ts +3 -2
  190. package/types/randomString.d.ts +2 -2
  191. package/types/replaceChar.d.ts +15 -11
  192. package/types/round.d.ts +2 -2
  193. package/types/safeDate.d.ts +24 -2
  194. package/types/setDataURLPrefix.d.ts +5 -5
  195. package/types/strlen.d.ts +1 -1
  196. package/types/times.d.ts +3 -2
  197. package/types/transformFieldNames.d.ts +12 -10
  198. package/types/treeToList.d.ts +1 -1
  199. package/types/utils/config.d.ts +6 -5
  200. package/types/utils/constants.d.ts +2 -2
  201. package/types/utils/convertToString.d.ts +1 -1
  202. package/types/utils/devWarn.d.ts +1 -1
  203. package/types/utils/math.util.d.ts +15 -9
  204. package/types/utils/type/index.d.ts +7 -0
  205. package/types/utils/type/isArguments.d.ts +1 -1
  206. package/types/utils/type/isArray.d.ts +1 -1
  207. package/types/utils/type/isArrayBuffer.d.ts +1 -1
  208. package/types/utils/type/isBlob.d.ts +1 -1
  209. package/types/utils/type/isBoolean.d.ts +1 -1
  210. package/types/utils/type/isDate.d.ts +1 -1
  211. package/types/utils/type/isError.d.ts +1 -1
  212. package/types/utils/type/isFunction.d.ts +1 -1
  213. package/types/utils/type/isMap.d.ts +1 -1
  214. package/types/utils/type/isNaN.d.ts +1 -1
  215. package/types/utils/type/isNil.d.ts +1 -1
  216. package/types/utils/type/isNull.d.ts +1 -1
  217. package/types/utils/type/isNumber.d.ts +1 -1
  218. package/types/utils/type/isObject.d.ts +1 -1
  219. package/types/utils/type/isRegExp.d.ts +1 -1
  220. package/types/utils/type/isSet.d.ts +1 -1
  221. package/types/utils/type/isString.d.ts +1 -1
  222. package/types/utils/type/isSymbol.d.ts +1 -1
  223. package/types/utils/type/isType.d.ts +1 -1
  224. package/types/utils/type/isUndefined.d.ts +1 -1
  225. package/types/utils/type/isWeakMap.d.ts +1 -1
  226. package/types/utils/type/isWeakSet.d.ts +1 -1
  227. package/types/validatePassword.d.ts +17 -48
  228. package/types/waitTime.d.ts +2 -2
  229. package/esm/interface.doc.js +0 -125
  230. package/esm/interface.type.js +0 -17
  231. package/esm/utils/type/index.js +0 -29
  232. package/esm/utils/type/isArguments.js +0 -22
  233. package/esm/utils/type/isArray.js +0 -22
  234. package/esm/utils/type/isArrayBuffer.js +0 -25
  235. package/esm/utils/type/isBoolean.js +0 -22
  236. package/esm/utils/type/isDate.js +0 -22
  237. package/esm/utils/type/isError.js +0 -22
  238. package/esm/utils/type/isFunction.js +0 -22
  239. package/esm/utils/type/isMap.js +0 -22
  240. package/esm/utils/type/isRegExp.js +0 -22
  241. package/esm/utils/type/isSet.js +0 -22
  242. package/esm/utils/type/isWeakMap.js +0 -22
  243. package/esm/utils/type/isWeakSet.js +0 -22
  244. package/lib/interface.doc.js +0 -127
  245. package/lib/interface.type.js +0 -5
  246. package/lib/utils/type/index.js +0 -146
  247. package/lib/utils/type/isArguments.js +0 -29
  248. package/lib/utils/type/isArray.js +0 -29
  249. package/lib/utils/type/isArrayBuffer.js +0 -32
  250. package/lib/utils/type/isBoolean.js +0 -29
  251. package/lib/utils/type/isDate.js +0 -29
  252. package/lib/utils/type/isError.js +0 -29
  253. package/lib/utils/type/isFunction.js +0 -29
  254. package/lib/utils/type/isMap.js +0 -29
  255. package/lib/utils/type/isRegExp.js +0 -29
  256. package/lib/utils/type/isSet.js +0 -29
  257. package/lib/utils/type/isWeakMap.js +0 -29
  258. package/lib/utils/type/isWeakSet.js +0 -29
  259. package/types/interface.type.d.ts +0 -2
@@ -1,191 +1,105 @@
1
- /**
2
- * 参考: https://github.com/nefe/number-precision/blob/master/src/index.ts
3
- *
4
- * 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
5
- * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
6
- */
7
-
8
- import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from './constants';
9
- import devWarn from './devWarn';
10
- import { isNumber, isString, isSymbol } from './type';
11
-
12
- /**
13
- * 将值转换为有效数值
14
- *
15
- * @param {*} value 要转换的值
16
- * @returns {number|string} 有效数值
17
- */
18
- export function transformEffectiveNumber(value) {
19
- /** @type {string|number|undefined} */
20
- var ret;
21
- if (isString(value)) {
22
- ret = value.trim(); // ' 15' ' 15 ' 兼容 Number(string) 处理
23
-
24
- if (ret === '') {
25
- ret = Number(ret);
26
- } else if (Number.isNaN(Number(ret))) {
27
- // string如果可以转换为number,默认不转换为number类型
28
- ret = Number.NaN;
1
+ import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from './constants.js';
2
+ import devWarn from './devWarn.js';
3
+ import isNumber from './type/isNumber.js';
4
+ import isString from './type/isString.js';
5
+ import isSymbol from './type/isSymbol.js';
6
+
7
+ function transformEffectiveNumber(value) {
8
+ var ret;
9
+ if (isString(value)) {
10
+ ret = value.trim();
11
+ if (ret === '') {
12
+ ret = Number(ret);
13
+ }
14
+ else if (Number.isNaN(Number(ret))) {
15
+ ret = Number.NaN;
16
+ }
29
17
  }
30
- } else if (isSymbol(value)) {
31
- // 例如 Symbol 包装器对象将会报错
32
- // symObj = Object(Symbol());
33
- // Number(symObj); // TypeError: Cannot convert a Symbol value to a number
34
- ret = Number.NaN;
35
- } else if (!isNumber(value)) {
36
- // 其余非数字类型通过 Number 转换
37
- ret = Number(value);
38
- } else {
39
- ret = value;
40
- }
41
- if (Number.isNaN(ret)) {
42
- return Number.NaN;
43
- }
44
-
45
- // @ts-ignore
46
- return ret;
47
- }
48
-
49
- /**
50
- * 是否为科学计数法数字
51
- *
52
- * @param {string} num 检查值
53
- * @returns {boolean}
54
- */
55
- export function isScientificNumber(num) {
56
- return /\d+\.?\d*e[\+\-]*\d+/i.test(num);
18
+ else if (isSymbol(value)) {
19
+ ret = Number.NaN;
20
+ }
21
+ else if (!isNumber(value)) {
22
+ ret = Number(value);
23
+ }
24
+ else {
25
+ ret = value;
26
+ }
27
+ if (Number.isNaN(ret)) {
28
+ return Number.NaN;
29
+ }
30
+ return ret;
57
31
  }
58
-
59
- /**
60
- * 把错误的数据转正
61
- *
62
- * @param {number} num 输入数
63
- * @param {number} [precision=12] 小数点的精度
64
- * @returns {number}
65
- * @example
66
- *
67
- * strip(0.09999999999999998)=0.1
68
- */
69
- export function strip(num) {
70
- var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
71
- return +parseFloat(num.toPrecision(precision));
32
+ function isScientificNumber(num) {
33
+ return /\d+\.?\d*e[+-]*\d+/i.test(num);
72
34
  }
73
-
74
- /**
75
- * 计算数字的小数点长度,支持科学记数法
76
- *
77
- * @param {number|string} num 输入数
78
- * @returns {number} 小数点长度
79
- */
80
- export function digitLength(num) {
81
- // Get digit length of e
82
- var eSplit = num.toString().split(/e/i);
83
- var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
84
- return len > 0 ? len : 0;
35
+ function strip(num, precision) {
36
+ if (precision === void 0) { precision = 12; }
37
+ return +parseFloat(num.toPrecision(precision));
85
38
  }
86
-
87
- /**
88
- * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
89
- *
90
- * @param {number|string} num 输入数
91
- * @returns {number}
92
- */
93
- export function float2Fixed(num) {
94
- var strNum = String(num);
95
- if (!isScientificNumber(strNum)) {
96
- return Number(strNum.replace('.', ''));
97
- }
98
- var dLen = digitLength(num);
99
- return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
39
+ function digitLength(num) {
40
+ var eSplit = num.toString().split(/e/i);
41
+ var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
42
+ return len > 0 ? len : 0;
100
43
  }
101
-
102
- /**
103
- * 检测数字是否越界,如果越界给出提示
104
- * @param {number} num 输入数
105
- * @returns
106
- */
107
- export function checkBoundary(num) {
108
- if (+num > MAX_SAFE_INTEGER || +num < MIN_SAFE_INTEGER) {
109
- devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
110
- }
44
+ function float2Fixed(num) {
45
+ var strNum = String(num);
46
+ if (!isScientificNumber(strNum)) {
47
+ return Number(strNum.replace('.', ''));
48
+ }
49
+ var dLen = digitLength(num);
50
+ return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
111
51
  }
112
-
113
- /**
114
- * 去掉左边数字0
115
- *
116
- * @param {string} num 数字字符串
117
- * @returns {string}
118
- */
119
- export function trimLeftZero(num) {
120
- var reg = /^([+-])?(0+)([0-9\.]+)$/;
121
- var result = reg.exec(num);
122
- var sign;
123
- if (result) {
124
- sign = result[1] || '';
125
- return sign + (result[3][0] === '.' ? '0' + result[3] : result[3]);
126
- }
127
- return num;
52
+ function checkBoundary(num) {
53
+ if (+num > MAX_SAFE_INTEGER || +num < MIN_SAFE_INTEGER) {
54
+ devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
55
+ }
128
56
  }
129
-
130
- /**
131
- * 科学计数法转换成普通数字
132
- *
133
- * JavaScript在以下情景会自动将数值转换为科学计数法:
134
- * 1.小数点前的数字个数大于等于22位
135
- * 2.小数点前边是0,小数点后十分位(包含十分位)之后连续零的个数大于等于6个
136
- *
137
- * @param {string | number} num 科学计数法数字
138
- * @returns {string | number} 转换后的数字字符串
139
- */
140
- export function scientificToNumber(num) {
141
- var strNum = String(num);
142
- if (!isScientificNumber(strNum)) {
57
+ function trimLeftZero(num) {
58
+ var reg = /^([+-])?(0+)([0-9.]+)$/;
59
+ var result = reg.exec(num);
60
+ var sign;
61
+ if (result) {
62
+ sign = result[1] || '';
63
+ return sign + (result[3][0] === '.' ? '0' + result[3] : result[3]);
64
+ }
143
65
  return num;
144
- }
145
-
146
- /** @type string */
147
- var ret;
148
- var zero = '0';
149
- var parts = strNum.toLowerCase().split('e');
150
- var e = parts.pop(); // 存储指数
151
- // @ts-ignore
152
- var l = Math.abs(e); // 取绝对值,l-1就是0的个数
153
- // @ts-ignore
154
- var sign = e / l; //判断正负
155
- var coeff_array = parts[0].split('.'); // 将系数按照小数点拆分
156
-
157
- // 如果是小数
158
- if (sign === -1) {
159
- // 整数部分
160
- var intVal = trimLeftZero(coeff_array[0]);
161
-
162
- // 整数部分大于科学计数后面部分
163
- // 如: 10e-1, 10.2e-1
164
- if (intVal.length > l) {
165
- var thanLen = intVal.length - l;
166
- var dec = coeff_array[1] || '';
167
- ret = intVal.slice(0, thanLen);
168
-
169
- // 处理 10e-1, 100e-1
170
- if (intVal.slice(thanLen) !== '0' || dec) {
171
- ret += '.' + intVal.slice(thanLen) + dec;
172
- }
173
- } else {
174
- // 整数部分小于等于科学计数后面部分
175
- // 如: 1e-1, 0.2e-1, 1.2e-2, 1.2e-1
176
- ret = zero + '.' + new Array(l - intVal.length + 1).join(zero) + coeff_array.join('');
66
+ }
67
+ function scientificToNumber(num) {
68
+ var strNum = String(num);
69
+ if (!isScientificNumber(strNum)) {
70
+ return num;
177
71
  }
178
- } else {
179
- // 小数部分
180
- var _dec = coeff_array[1] || '';
181
-
182
- // 如果是整数,将整数除第一位之外的非零数字计入位数,相应的减少0的个数
183
- if (l - _dec.length < 0) {
184
- ret = trimLeftZero(coeff_array[0] + _dec.substring(0, l)) + '.' + _dec.substring(l);
185
- } else {
186
- // 拼接字符串,如果是整数,不需要拼接小数点
187
- ret = coeff_array.join('') + new Array(l - _dec.length + 1).join(zero);
72
+ var ret;
73
+ var zero = '0';
74
+ var parts = strNum.toLowerCase().split('e');
75
+ var e = parts.pop();
76
+ var l = Math.abs(e);
77
+ var sign = e / l;
78
+ var coeff_array = parts[0].split('.');
79
+ if (sign === -1) {
80
+ var intVal = trimLeftZero(coeff_array[0]);
81
+ if (intVal.length > l) {
82
+ var thanLen = intVal.length - l;
83
+ var dec = coeff_array[1] || '';
84
+ ret = intVal.slice(0, thanLen);
85
+ if (intVal.slice(thanLen) !== '0' || dec) {
86
+ ret += '.' + intVal.slice(thanLen) + dec;
87
+ }
88
+ }
89
+ else {
90
+ ret = zero + '.' + new Array(l - intVal.length + 1).join(zero) + coeff_array.join('');
91
+ }
188
92
  }
189
- }
190
- return trimLeftZero(ret);
191
- }
93
+ else {
94
+ var dec = coeff_array[1] || '';
95
+ if (l - dec.length < 0) {
96
+ ret = trimLeftZero(coeff_array[0] + dec.substring(0, l)) + '.' + dec.substring(l);
97
+ }
98
+ else {
99
+ ret = coeff_array.join('') + new Array(l - dec.length + 1).join(zero);
100
+ }
101
+ }
102
+ return trimLeftZero(ret);
103
+ }
104
+
105
+ export { checkBoundary, digitLength, float2Fixed, isScientificNumber, scientificToNumber, strip, transformEffectiveNumber, trimLeftZero };
@@ -1,27 +1,7 @@
1
- import isType from './isType';
1
+ import isType from './isType.js';
2
2
 
3
- /**
4
- * 检查值是否为Blob对象<br/><br/>
5
- *
6
- * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
7
- *
8
- * @static
9
- * @alias module:Type.isBlob
10
- * @since 4.16.0
11
- * @param {*} value 检查值
12
- * @returns {boolean} 是否为Blob对象
13
- * @example
14
- *
15
- * isBlob(new Blob(['a']))
16
- * // => true
17
- *
18
- * isBlob({})
19
- * // => false
20
- *
21
- * isBlob('2012')
22
- * // => false
23
- */
24
3
  function isBlob(value) {
25
- return isType(value, 'Blob');
4
+ return isType(value, 'Blob');
26
5
  }
27
- export default isBlob;
6
+
7
+ export { isBlob as default };
@@ -1,22 +1,7 @@
1
- import isType from './isType';
1
+ import isType from './isType.js';
2
2
 
3
- /**
4
- * 检查值是否为NaN
5
- *
6
- * @static
7
- * @alias module:Type.isNaN
8
- * @since 1.1.0
9
- * @param {*} value 检查值
10
- * @returns {boolean} 是否为NaN
11
- * @example
12
- *
13
- * isNaN(NaN)
14
- * // => true
15
- *
16
- * isNaN(1)
17
- * // => false
18
- */
19
3
  function _isNaN(value) {
20
- return isType(value, 'Number') && isNaN(value);
4
+ return isType(value, 'Number') && isNaN(value);
21
5
  }
22
- export default _isNaN;
6
+
7
+ export { _isNaN as default };
@@ -1,16 +1,8 @@
1
- import isUndefined from './isUndefined';
2
- import isNull from './isNull';
1
+ import isUndefined from './isUndefined.js';
2
+ import isNull from './isNull.js';
3
3
 
4
- /**
5
- * 检查值是否为 undefined 或 null
6
- *
7
- * @static
8
- * @alias module:Type.isNaN
9
- * @since 4.3.0
10
- * @param {*} value 检查值
11
- * @returns {boolean} 是否为 undefined 或 null
12
- */
13
4
  function isNil(value) {
14
- return isUndefined(value) || isNull(value);
5
+ return isUndefined(value) || isNull(value);
15
6
  }
16
- export default isNil;
7
+
8
+ export { isNil as default };
@@ -1,20 +1,5 @@
1
- /**
2
- * 检查值是否为Null
3
- *
4
- * @static
5
- * @alias module:Type.isNull
6
- * @since 1.1.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为Null
9
- * @example
10
- *
11
- * isNull(null)
12
- * // => true
13
- *
14
- * isNull(void 0)
15
- * // => false
16
- */
17
1
  function isNull(value) {
18
- return value === null;
2
+ return value === null;
19
3
  }
20
- export default isNull;
4
+
5
+ export { isNull as default };
@@ -1,31 +1,7 @@
1
- import isType from './isType';
1
+ import isType from './isType.js';
2
2
 
3
- /**
4
- * 检查值是否为Number
5
- *
6
- * @static
7
- * @alias module:Type.isNumber
8
- * @since 1.1.0
9
- * @param {*} value 检查值
10
- * @returns {boolean} 是否为Number
11
- * @example
12
- *
13
- * isNumber(1)
14
- * // => true
15
- *
16
- * isNumber(Number.MIN_VALUE)
17
- * // => true
18
- *
19
- * isNumber(Infinity)
20
- * // => true
21
- *
22
- * isNumber(NaN)
23
- * // => true
24
- *
25
- * isNumber('1')
26
- * // => false
27
- */
28
3
  function isNumber(value) {
29
- return isType(value, 'Number');
4
+ return isType(value, 'Number');
30
5
  }
31
- export default isNumber;
6
+
7
+ export { isNumber as default };
@@ -1,25 +1,6 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- /**
3
- * 检查值是否为Object
4
- *
5
- * @static
6
- * @alias module:Type.isObject
7
- * @since 1.1.0
8
- * @param {*} value 检查值
9
- * @returns {boolean} 是否为Object
10
- * @example
11
- *
12
- * isObject({})
13
- * // => true
14
- *
15
- * isObject([1,2,3])
16
- * // => true
17
- *
18
- * isObject(null)
19
- * // => false
20
- */
21
1
  function isObject(value) {
22
- var type = _typeof(value);
23
- return value != null && (type === 'object' || type === 'function');
2
+ var type = typeof value;
3
+ return value != null && (type === 'object' || type === 'function');
24
4
  }
25
- export default isObject;
5
+
6
+ export { isObject as default };
@@ -1,22 +1,7 @@
1
- import isType from './isType';
1
+ import isType from './isType.js';
2
2
 
3
- /**
4
- * 检查值是否为String
5
- *
6
- * @static
7
- * @alias module:Type.isString
8
- * @since 1.1.0
9
- * @param {*} value 检查值
10
- * @returns {boolean} 是否为String
11
- * @example
12
- *
13
- * isString('abc')
14
- * // => true
15
- *
16
- * isString(1)
17
- * // => false
18
- */
19
3
  function isString(value) {
20
- return isType(value, 'String');
4
+ return isType(value, 'String');
21
5
  }
22
- export default isString;
6
+
7
+ export { isString as default };
@@ -1,22 +1,7 @@
1
- import isType from './isType';
1
+ import isType from './isType.js';
2
2
 
3
- /**
4
- * 检查值是否为Symbol
5
- *
6
- * @static
7
- * @alias module:Type.isSymbol
8
- * @since 1.1.0
9
- * @param {*} value 检查值
10
- * @returns {boolean} 是否为Symbol
11
- * @example
12
- *
13
- * isSymbol(Symbol.iterator)
14
- * // => true
15
- *
16
- * isSymbol("abc")
17
- * // => false
18
- */
19
3
  function isSymbol(value) {
20
- return isType(value, 'Symbol');
4
+ return isType(value, 'Symbol');
21
5
  }
22
- export default isSymbol;
6
+
7
+ export { isSymbol as default };
@@ -1,15 +1,6 @@
1
1
  var toString = Object.prototype.toString;
2
-
3
- /**
4
- * 检测值的 `toString` 类型
5
- *
6
- * @private
7
- * @since 1.1.0
8
- * @param {*} value 检查值
9
- * @param {string} typename 类型名称
10
- * @returns {boolean} 返回值的 `toString` 类型是否匹配
11
- */
12
2
  function isType(value, typename) {
13
- return toString.call(value) === "[object ".concat(typename, "]");
3
+ return toString.call(value) === "[object ".concat(typename, "]");
14
4
  }
15
- export default isType;
5
+
6
+ export { isType as default };
@@ -1,23 +1,5 @@
1
- /**
2
- * 检查值是否为Undefined
3
- *
4
- * @static
5
- * @alias module:Type.isUndefined
6
- * @since 1.1.0
7
- * @param {*} value 检查值
8
- * @returns {boolean} 是否为Undefined
9
- * @example
10
- *
11
- * isUndefined(undefined)
12
- * // => true
13
- *
14
- * isUndefined(void 0)
15
- * // => true
16
- *
17
- * isUndefined(null)
18
- * // => false
19
- */
20
1
  function isUndefined(value) {
21
- return value === void 0;
2
+ return value === void 0;
22
3
  }
23
- export default isUndefined;
4
+
5
+ export { isUndefined as default };