util-helpers 4.13.1 → 4.14.0

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 (174) hide show
  1. package/README.md +16 -6
  2. package/dist/util-helpers.js +935 -536
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/blobToDataURL.js +2 -4
  7. package/esm/bytesToSize.js +13 -5
  8. package/esm/calculateCursorPosition.js +7 -12
  9. package/esm/dataURLToBlob.js +2 -5
  10. package/esm/divide.js +9 -13
  11. package/esm/findTreeNode.js +66 -0
  12. package/esm/findTreeSelect.js +80 -0
  13. package/esm/formatBankCard.js +11 -11
  14. package/esm/formatMobile.js +11 -14
  15. package/esm/formatMoney.js +24 -35
  16. package/esm/index.js +9 -4
  17. package/esm/isBankCard.js +9 -13
  18. package/esm/isBusinessLicense.js +19 -20
  19. package/esm/isChinese.js +6 -6
  20. package/esm/isEmail.js +3 -3
  21. package/esm/isHMCard.js +3 -3
  22. package/esm/isIPv4.js +3 -3
  23. package/esm/isIPv6.js +3 -3
  24. package/esm/isIdCard.js +9 -17
  25. package/esm/isMobile.js +3 -3
  26. package/esm/isPassport.js +3 -3
  27. package/esm/isPassword.js +6 -7
  28. package/esm/isPostcode.js +3 -3
  29. package/esm/isPromiseLike.js +0 -2
  30. package/esm/isQQ.js +3 -3
  31. package/esm/isSocialCreditCode.js +29 -28
  32. package/esm/isSwiftCode.js +1 -2
  33. package/esm/isTWCard.js +6 -7
  34. package/esm/isTelephone.js +3 -3
  35. package/esm/isUrl.js +7 -3
  36. package/esm/isVehicle.js +3 -3
  37. package/esm/isWX.js +3 -3
  38. package/esm/listToTree.js +122 -0
  39. package/esm/minus.js +7 -11
  40. package/esm/normalizeString.js +1 -3
  41. package/esm/numberToChinese.js +43 -52
  42. package/esm/padZero.js +1 -5
  43. package/esm/parseIdCard.js +27 -23
  44. package/esm/plus.js +7 -11
  45. package/esm/randomString.js +2 -8
  46. package/esm/replaceChar.js +11 -16
  47. package/esm/round.js +4 -5
  48. package/esm/safeDate.js +5 -7
  49. package/esm/setDataURLPrefix.js +0 -1
  50. package/esm/strlen.js +1 -5
  51. package/esm/times.js +7 -11
  52. package/esm/transformFieldNames.doc.js +34 -0
  53. package/esm/transformFieldNames.js +98 -0
  54. package/esm/transformFieldNames.type.js +19 -0
  55. package/esm/treeToList.js +88 -0
  56. package/esm/utils/config.js +4 -4
  57. package/esm/utils/constants.js +2 -2
  58. package/esm/utils/convertToString.js +1 -2
  59. package/esm/utils/devWarn.js +1 -3
  60. package/esm/utils/math.util.js +20 -29
  61. package/esm/utils/type/index.js +1 -1
  62. package/esm/utils/type/isArguments.js +1 -2
  63. package/esm/utils/type/isArray.js +1 -2
  64. package/esm/utils/type/isBoolean.js +1 -2
  65. package/esm/utils/type/isDate.js +1 -2
  66. package/esm/utils/type/isError.js +1 -2
  67. package/esm/utils/type/isFunction.js +1 -2
  68. package/esm/utils/type/isMap.js +1 -2
  69. package/esm/utils/type/isNaN.js +1 -2
  70. package/esm/utils/type/isNil.js +1 -2
  71. package/esm/utils/type/isNull.js +0 -1
  72. package/esm/utils/type/isNumber.js +1 -2
  73. package/esm/utils/type/isObject.js +0 -3
  74. package/esm/utils/type/isRegExp.js +1 -2
  75. package/esm/utils/type/isSet.js +1 -2
  76. package/esm/utils/type/isString.js +1 -2
  77. package/esm/utils/type/isSymbol.js +1 -2
  78. package/esm/utils/type/isType.js +1 -2
  79. package/esm/utils/type/isUndefined.js +0 -1
  80. package/esm/utils/type/isWeakMap.js +1 -2
  81. package/esm/utils/type/isWeakSet.js +1 -2
  82. package/esm/validatePassword.js +27 -50
  83. package/esm/waitTime.js +0 -1
  84. package/lib/blobToDataURL.js +2 -5
  85. package/lib/bytesToSize.js +13 -6
  86. package/lib/calculateCursorPosition.js +4 -13
  87. package/lib/dataURLToBlob.js +2 -6
  88. package/lib/divide.js +8 -22
  89. package/lib/findTreeNode.js +76 -0
  90. package/lib/findTreeSelect.js +86 -0
  91. package/lib/formatBankCard.js +10 -13
  92. package/lib/formatMobile.js +10 -16
  93. package/lib/formatMoney.js +25 -47
  94. package/lib/index.js +115 -126
  95. package/lib/isBankCard.js +7 -15
  96. package/lib/isBusinessLicense.js +17 -22
  97. package/lib/isChinese.js +6 -9
  98. package/lib/isEmail.js +1 -5
  99. package/lib/isHMCard.js +1 -5
  100. package/lib/isIPv4.js +1 -5
  101. package/lib/isIPv6.js +1 -5
  102. package/lib/isIdCard.js +7 -19
  103. package/lib/isMobile.js +1 -5
  104. package/lib/isPassport.js +1 -5
  105. package/lib/isPassword.js +5 -9
  106. package/lib/isPostcode.js +1 -5
  107. package/lib/isPromiseLike.js +1 -4
  108. package/lib/isQQ.js +1 -5
  109. package/lib/isSocialCreditCode.js +27 -30
  110. package/lib/isSwiftCode.js +1 -5
  111. package/lib/isTWCard.js +4 -9
  112. package/lib/isTelephone.js +1 -5
  113. package/lib/isUrl.js +5 -5
  114. package/lib/isVehicle.js +1 -5
  115. package/lib/isWX.js +1 -5
  116. package/lib/listToTree.js +131 -0
  117. package/lib/minus.js +6 -20
  118. package/lib/normalizeString.js +0 -6
  119. package/lib/numberToChinese.js +41 -55
  120. package/lib/padZero.js +0 -7
  121. package/lib/parseIdCard.js +30 -29
  122. package/lib/plus.js +6 -20
  123. package/lib/randomString.js +2 -8
  124. package/lib/replaceChar.js +10 -18
  125. package/lib/round.js +3 -9
  126. package/lib/safeDate.js +4 -13
  127. package/lib/setDataURLPrefix.js +0 -2
  128. package/lib/strlen.js +0 -7
  129. package/lib/times.js +6 -18
  130. package/lib/transformFieldNames.doc.js +41 -0
  131. package/lib/transformFieldNames.js +104 -0
  132. package/lib/transformFieldNames.type.js +5 -0
  133. package/lib/treeToList.js +96 -0
  134. package/lib/utils/config.js +6 -6
  135. package/lib/utils/constants.js +2 -2
  136. package/lib/utils/convertToString.js +0 -4
  137. package/lib/utils/devWarn.js +0 -4
  138. package/lib/utils/math.util.js +23 -45
  139. package/lib/utils/type/index.js +20 -39
  140. package/lib/utils/type/isArguments.js +0 -4
  141. package/lib/utils/type/isArray.js +0 -4
  142. package/lib/utils/type/isBoolean.js +0 -4
  143. package/lib/utils/type/isDate.js +0 -4
  144. package/lib/utils/type/isError.js +0 -4
  145. package/lib/utils/type/isFunction.js +0 -4
  146. package/lib/utils/type/isMap.js +0 -4
  147. package/lib/utils/type/isNaN.js +0 -4
  148. package/lib/utils/type/isNil.js +0 -5
  149. package/lib/utils/type/isNull.js +0 -2
  150. package/lib/utils/type/isNumber.js +0 -4
  151. package/lib/utils/type/isObject.js +1 -5
  152. package/lib/utils/type/isRegExp.js +0 -4
  153. package/lib/utils/type/isSet.js +0 -4
  154. package/lib/utils/type/isString.js +0 -4
  155. package/lib/utils/type/isSymbol.js +0 -4
  156. package/lib/utils/type/isType.js +1 -2
  157. package/lib/utils/type/isUndefined.js +0 -2
  158. package/lib/utils/type/isWeakMap.js +0 -4
  159. package/lib/utils/type/isWeakSet.js +0 -4
  160. package/lib/validatePassword.js +27 -53
  161. package/lib/waitTime.js +0 -2
  162. package/package.json +6 -5
  163. package/types/bytesToSize.d.ts +9 -1
  164. package/types/findTreeNode.d.ts +26 -0
  165. package/types/findTreeSelect.d.ts +26 -0
  166. package/types/formatBankCard.d.ts +3 -3
  167. package/types/formatMobile.d.ts +4 -4
  168. package/types/index.d.ts +5 -0
  169. package/types/isIdCard.d.ts +2 -0
  170. package/types/isUrl.d.ts +2 -0
  171. package/types/listToTree.d.ts +41 -0
  172. package/types/transformFieldNames.d.ts +34 -0
  173. package/types/transformFieldNames.type.d.ts +2 -0
  174. package/types/treeToList.d.ts +20 -0
@@ -4,20 +4,20 @@
4
4
  * 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
5
5
  * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
6
6
  */
7
+
7
8
  import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from './constants';
8
9
  import devWarn from './devWarn';
9
10
  import { isNumber, isString, isSymbol } from './type';
11
+
10
12
  /**
11
13
  * 将值转换为有效数值
12
14
  *
13
15
  * @param {*} value 要转换的值
14
16
  * @returns {number|string} 有效数值
15
17
  */
16
-
17
18
  export function transformEffectiveNumber(value) {
18
19
  /** @type {string|number|undefined} */
19
20
  var ret;
20
-
21
21
  if (isString(value)) {
22
22
  ret = value.trim(); // ' 15' ' 15 ' 兼容 Number(string) 处理
23
23
 
@@ -38,24 +38,24 @@ export function transformEffectiveNumber(value) {
38
38
  } else {
39
39
  ret = value;
40
40
  }
41
-
42
41
  if (Number.isNaN(ret)) {
43
42
  return Number.NaN;
44
- } // @ts-ignore
45
-
43
+ }
46
44
 
45
+ // @ts-ignore
47
46
  return ret;
48
47
  }
48
+
49
49
  /**
50
50
  * 是否为科学计数法数字
51
51
  *
52
52
  * @param {string} num 检查值
53
53
  * @returns {boolean}
54
54
  */
55
-
56
55
  export function isScientificNumber(num) {
57
56
  return /\d+\.?\d*e[\+\-]*\d+/i.test(num);
58
57
  }
58
+
59
59
  /**
60
60
  * 把错误的数据转正
61
61
  *
@@ -66,71 +66,67 @@ export function isScientificNumber(num) {
66
66
  *
67
67
  * strip(0.09999999999999998)=0.1
68
68
  */
69
-
70
69
  export function strip(num) {
71
70
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
72
71
  return +parseFloat(num.toPrecision(precision));
73
72
  }
73
+
74
74
  /**
75
75
  * 计算数字的小数点长度,支持科学记数法
76
76
  *
77
77
  * @param {number|string} num 输入数
78
78
  * @returns {number} 小数点长度
79
79
  */
80
-
81
80
  export function digitLength(num) {
82
81
  // Get digit length of e
83
82
  var eSplit = num.toString().split(/e/i);
84
83
  var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
85
84
  return len > 0 ? len : 0;
86
85
  }
86
+
87
87
  /**
88
88
  * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
89
89
  *
90
90
  * @param {number|string} num 输入数
91
91
  * @returns {number}
92
92
  */
93
-
94
93
  export function float2Fixed(num) {
95
94
  var strNum = String(num);
96
-
97
95
  if (!isScientificNumber(strNum)) {
98
96
  return Number(strNum.replace('.', ''));
99
97
  }
100
-
101
98
  var dLen = digitLength(num);
102
99
  return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
103
100
  }
101
+
104
102
  /**
105
103
  * 检测数字是否越界,如果越界给出提示
106
104
  * @param {number} num 输入数
107
105
  * @returns
108
106
  */
109
-
110
107
  export function checkBoundary(num) {
111
108
  if (+num > MAX_SAFE_INTEGER || +num < MIN_SAFE_INTEGER) {
112
109
  devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
113
110
  }
114
111
  }
112
+
115
113
  /**
116
114
  * 去掉左边数字0
117
115
  *
118
116
  * @param {string} num 数字字符串
119
117
  * @returns {string}
120
118
  */
121
-
122
119
  export function trimLeftZero(num) {
123
120
  var reg = /^([+-])?(0+)([0-9\.]+)$/;
124
121
  var result = reg.exec(num);
125
122
  var sign;
126
-
127
123
  if (result) {
128
124
  sign = result[1] || '';
129
125
  return sign + (result[3][0] === '.' ? '0' + result[3] : result[3]);
130
126
  }
131
-
132
127
  return num;
133
128
  }
129
+
134
130
  /**
135
131
  * 科学计数法转换成普通数字
136
132
  *
@@ -141,40 +137,36 @@ export function trimLeftZero(num) {
141
137
  * @param {string | number} num 科学计数法数字
142
138
  * @returns {string | number} 转换后的数字字符串
143
139
  */
144
-
145
140
  export function scientificToNumber(num) {
146
141
  var strNum = String(num);
147
-
148
142
  if (!isScientificNumber(strNum)) {
149
143
  return num;
150
144
  }
151
- /** @type string */
152
-
153
145
 
146
+ /** @type string */
154
147
  var ret;
155
148
  var zero = '0';
156
149
  var parts = strNum.toLowerCase().split('e');
157
150
  var e = parts.pop(); // 存储指数
158
151
  // @ts-ignore
159
-
160
152
  var l = Math.abs(e); // 取绝对值,l-1就是0的个数
161
153
  // @ts-ignore
162
-
163
154
  var sign = e / l; //判断正负
164
-
165
155
  var coeff_array = parts[0].split('.'); // 将系数按照小数点拆分
166
- // 如果是小数
167
156
 
157
+ // 如果是小数
168
158
  if (sign === -1) {
169
159
  // 整数部分
170
- var intVal = trimLeftZero(coeff_array[0]); // 整数部分大于科学计数后面部分
171
- // 如: 10e-1, 10.2e-1
160
+ var intVal = trimLeftZero(coeff_array[0]);
172
161
 
162
+ // 整数部分大于科学计数后面部分
163
+ // 如: 10e-1, 10.2e-1
173
164
  if (intVal.length > l) {
174
165
  var thanLen = intVal.length - l;
175
166
  var dec = coeff_array[1] || '';
176
- ret = intVal.slice(0, thanLen); // 处理 10e-1, 100e-1
167
+ ret = intVal.slice(0, thanLen);
177
168
 
169
+ // 处理 10e-1, 100e-1
178
170
  if (intVal.slice(thanLen) !== '0' || dec) {
179
171
  ret += '.' + intVal.slice(thanLen) + dec;
180
172
  }
@@ -185,9 +177,9 @@ export function scientificToNumber(num) {
185
177
  }
186
178
  } else {
187
179
  // 小数部分
188
- var _dec = coeff_array[1] || ''; // 如果是整数,将整数除第一位之外的非零数字计入位数,相应的减少0的个数
189
-
180
+ var _dec = coeff_array[1] || '';
190
181
 
182
+ // 如果是整数,将整数除第一位之外的非零数字计入位数,相应的减少0的个数
191
183
  if (l - _dec.length < 0) {
192
184
  ret = trimLeftZero(coeff_array[0] + _dec.substring(0, l)) + '.' + _dec.substring(l);
193
185
  } else {
@@ -195,6 +187,5 @@ export function scientificToNumber(num) {
195
187
  ret = coeff_array.join('') + new Array(l - _dec.length + 1).join(zero);
196
188
  }
197
189
  }
198
-
199
190
  return trimLeftZero(ret);
200
191
  }
@@ -16,6 +16,7 @@ import isWeakMap from './isWeakMap';
16
16
  import isSet from './isSet';
17
17
  import isWeakSet from './isWeakSet';
18
18
  import isUndefined from './isUndefined';
19
+
19
20
  /**
20
21
  * 类型检测
21
22
  *
@@ -23,5 +24,4 @@ import isUndefined from './isUndefined';
23
24
  * @ignore
24
25
  * @since 1.1.0
25
26
  */
26
-
27
27
  export { isArguments, isArray, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Arguments
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isArguments([1, 2, 3])
16
17
  * // => false
17
18
  */
18
-
19
19
  function isArguments(value) {
20
20
  return isType(value, 'Arguments');
21
21
  }
22
-
23
22
  export default isArguments;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Array
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isArray(1)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isArray(value) {
20
20
  return Array.isArray(value) || isType(value, 'Array');
21
21
  }
22
-
23
22
  export default isArray;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Boolean
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isBoolean(null)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isBoolean(value) {
20
20
  return value === true || value === false || isType(value, 'Boolean');
21
21
  }
22
-
23
22
  export default isBoolean;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Date
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isDate('Mon April 23 2012')
16
17
  * // => false
17
18
  */
18
-
19
19
  function isDate(value) {
20
20
  return isType(value, 'Date');
21
21
  }
22
-
23
22
  export default isDate;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isError(Error)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isError(value) {
20
20
  return isType(value, 'Error') || isType(value, 'DOMException');
21
21
  }
22
-
23
22
  export default isError;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Function|AsyncFunction|GeneratorFunction|Proxy
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isFunction(/abc/)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isFunction(value) {
20
20
  return isType(value, 'Function') || isType(value, 'AsyncFunction') || isType(value, 'GeneratorFunction') || isType(value, 'Proxy');
21
21
  }
22
-
23
22
  export default isFunction;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Map
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isMap(new WeakMap)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isMap(value) {
20
20
  return isType(value, 'Map');
21
21
  }
22
-
23
22
  export default isMap;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为NaN
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isNaN(1)
16
17
  * // => false
17
18
  */
18
-
19
19
  function _isNaN(value) {
20
20
  return isType(value, 'Number') && isNaN(value);
21
21
  }
22
-
23
22
  export default _isNaN;
@@ -1,5 +1,6 @@
1
1
  import isUndefined from './isUndefined';
2
2
  import isNull from './isNull';
3
+
3
4
  /**
4
5
  * 检查值是否为 undefined 或 null
5
6
  *
@@ -9,9 +10,7 @@ import isNull from './isNull';
9
10
  * @param {*} value 检查值
10
11
  * @returns {boolean} 是否为 undefined 或 null
11
12
  */
12
-
13
13
  function isNil(value) {
14
14
  return isUndefined(value) || isNull(value);
15
15
  }
16
-
17
16
  export default isNil;
@@ -17,5 +17,4 @@
17
17
  function isNull(value) {
18
18
  return value === null;
19
19
  }
20
-
21
20
  export default isNull;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Number
4
5
  *
@@ -24,9 +25,7 @@ import isType from './isType';
24
25
  * isNumber('1')
25
26
  * // => false
26
27
  */
27
-
28
28
  function isNumber(value) {
29
29
  return isType(value, 'Number');
30
30
  }
31
-
32
31
  export default isNumber;
@@ -1,5 +1,4 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
-
3
2
  /**
4
3
  * 检查值是否为Object
5
4
  *
@@ -21,8 +20,6 @@ import _typeof from "@babel/runtime/helpers/typeof";
21
20
  */
22
21
  function isObject(value) {
23
22
  var type = _typeof(value);
24
-
25
23
  return value != null && (type === 'object' || type === 'function');
26
24
  }
27
-
28
25
  export default isObject;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为RegExp
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isRegExp('/abc/')
16
17
  * // => false
17
18
  */
18
-
19
19
  function isRegExp(value) {
20
20
  return isType(value, 'RegExp');
21
21
  }
22
-
23
22
  export default isRegExp;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Set
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isSet(new WeakSet)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isSet(value) {
20
20
  return isType(value, 'Set');
21
21
  }
22
-
23
22
  export default isSet;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为String
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isString(1)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isString(value) {
20
20
  return isType(value, 'String');
21
21
  }
22
-
23
22
  export default isString;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为Symbol
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isSymbol("abc")
16
17
  * // => false
17
18
  */
18
-
19
19
  function isSymbol(value) {
20
20
  return isType(value, 'Symbol');
21
21
  }
22
-
23
22
  export default isSymbol;
@@ -1,4 +1,5 @@
1
1
  var toString = Object.prototype.toString;
2
+
2
3
  /**
3
4
  * 检测值的 `toString` 类型
4
5
  *
@@ -8,9 +9,7 @@ var toString = Object.prototype.toString;
8
9
  * @param {string} typename 类型名称
9
10
  * @returns {boolean} 返回值的 `toString` 类型是否匹配
10
11
  */
11
-
12
12
  function isType(value, typename) {
13
13
  return toString.call(value) === "[object ".concat(typename, "]");
14
14
  }
15
-
16
15
  export default isType;
@@ -20,5 +20,4 @@
20
20
  function isUndefined(value) {
21
21
  return value === void 0;
22
22
  }
23
-
24
23
  export default isUndefined;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为WeakMap
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isWeakMap(new Map)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isWeakMap(value) {
20
20
  return isType(value, 'WeakMap');
21
21
  }
22
-
23
22
  export default isWeakMap;
@@ -1,4 +1,5 @@
1
1
  import isType from './isType';
2
+
2
3
  /**
3
4
  * 检查值是否为WeakSet
4
5
  *
@@ -15,9 +16,7 @@ import isType from './isType';
15
16
  * isWeakSet(new Set)
16
17
  * // => false
17
18
  */
18
-
19
19
  function isWeakSet(value) {
20
20
  return isType(value, 'WeakSet');
21
21
  }
22
-
23
22
  export default isWeakSet;