util-helpers 4.12.4 → 4.12.7

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 (132) hide show
  1. package/README.md +9 -5
  2. package/dist/util-helpers.js +225 -363
  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/bytesToSize.js +5 -11
  7. package/esm/calculateCursorPosition.js +1 -1
  8. package/esm/dataURLToBlob.js +1 -1
  9. package/esm/divide.js +1 -0
  10. package/esm/formatBankCard.js +4 -8
  11. package/esm/formatMobile.js +9 -7
  12. package/esm/formatMoney.js +8 -14
  13. package/esm/isBankCard.js +6 -11
  14. package/esm/isBusinessLicense.js +7 -10
  15. package/esm/isChinese.js +10 -17
  16. package/esm/isEmail.js +2 -5
  17. package/esm/isHMCard.js +8 -8
  18. package/esm/isIPv4.js +4 -11
  19. package/esm/isIPv6.js +11 -29
  20. package/esm/isIdCard.js +9 -12
  21. package/esm/isMobile.js +2 -5
  22. package/esm/isPassport.js +2 -5
  23. package/esm/isPassword.js +14 -21
  24. package/esm/isPostcode.js +2 -5
  25. package/esm/isPromiseLike.js +4 -8
  26. package/esm/isQQ.js +2 -5
  27. package/esm/isSocialCreditCode.js +6 -11
  28. package/esm/isSwiftCode.js +5 -5
  29. package/esm/isTWCard.js +7 -4
  30. package/esm/isTelephone.js +7 -10
  31. package/esm/isUrl.js +8 -20
  32. package/esm/isVehicle.js +9 -14
  33. package/esm/isWX.js +2 -5
  34. package/esm/minus.js +4 -8
  35. package/esm/normalizeString.js +2 -0
  36. package/esm/numberToChinese.js +13 -19
  37. package/esm/padZero.js +9 -8
  38. package/esm/parseIdCard.js +8 -17
  39. package/esm/plus.js +4 -8
  40. package/esm/randomString.js +2 -0
  41. package/esm/replaceChar.js +9 -17
  42. package/esm/round.js +4 -8
  43. package/esm/safeDate.js +2 -0
  44. package/esm/setDataURLPrefix.js +2 -0
  45. package/esm/times.js +4 -8
  46. package/esm/utils/config.js +1 -1
  47. package/esm/utils/math.util.js +4 -9
  48. package/esm/waitTime.js +3 -1
  49. package/lib/bytesToSize.js +5 -11
  50. package/lib/calculateCursorPosition.js +1 -1
  51. package/lib/dataURLToBlob.js +1 -1
  52. package/lib/divide.js +1 -0
  53. package/lib/formatBankCard.js +4 -8
  54. package/lib/formatMobile.js +9 -7
  55. package/lib/formatMoney.js +8 -14
  56. package/lib/isBankCard.js +6 -11
  57. package/lib/isBusinessLicense.js +7 -10
  58. package/lib/isChinese.js +10 -17
  59. package/lib/isEmail.js +2 -5
  60. package/lib/isHMCard.js +8 -8
  61. package/lib/isIPv4.js +4 -11
  62. package/lib/isIPv6.js +11 -29
  63. package/lib/isIdCard.js +9 -12
  64. package/lib/isMobile.js +2 -5
  65. package/lib/isPassport.js +2 -5
  66. package/lib/isPassword.js +14 -21
  67. package/lib/isPostcode.js +2 -5
  68. package/lib/isPromiseLike.js +4 -8
  69. package/lib/isQQ.js +2 -5
  70. package/lib/isSocialCreditCode.js +6 -11
  71. package/lib/isSwiftCode.js +5 -5
  72. package/lib/isTWCard.js +7 -4
  73. package/lib/isTelephone.js +7 -10
  74. package/lib/isUrl.js +8 -20
  75. package/lib/isVehicle.js +9 -14
  76. package/lib/isWX.js +2 -5
  77. package/lib/minus.js +4 -8
  78. package/lib/normalizeString.js +2 -0
  79. package/lib/numberToChinese.js +13 -19
  80. package/lib/padZero.js +9 -8
  81. package/lib/parseIdCard.js +8 -19
  82. package/lib/plus.js +4 -8
  83. package/lib/randomString.js +2 -0
  84. package/lib/replaceChar.js +9 -17
  85. package/lib/round.js +4 -8
  86. package/lib/safeDate.js +2 -0
  87. package/lib/setDataURLPrefix.js +2 -0
  88. package/lib/times.js +4 -8
  89. package/lib/utils/config.js +1 -1
  90. package/lib/utils/math.util.js +4 -9
  91. package/lib/waitTime.js +3 -1
  92. package/package.json +1 -1
  93. package/types/src/bytesToSize.d.ts +4 -10
  94. package/types/src/dataURLToBlob.d.ts +1 -1
  95. package/types/src/divide.d.ts +1 -0
  96. package/types/src/formatBankCard.d.ts +4 -8
  97. package/types/src/formatMobile.d.ts +9 -7
  98. package/types/src/formatMoney.d.ts +8 -14
  99. package/types/src/isBankCard.d.ts +5 -10
  100. package/types/src/isBusinessLicense.d.ts +6 -9
  101. package/types/src/isChinese.d.ts +9 -16
  102. package/types/src/isEmail.d.ts +2 -5
  103. package/types/src/isHMCard.d.ts +8 -8
  104. package/types/src/isIPv4.d.ts +4 -11
  105. package/types/src/isIPv6.d.ts +11 -29
  106. package/types/src/isIdCard.d.ts +8 -11
  107. package/types/src/isMobile.d.ts +2 -5
  108. package/types/src/isPassport.d.ts +2 -5
  109. package/types/src/isPassword.d.ts +10 -17
  110. package/types/src/isPostcode.d.ts +2 -5
  111. package/types/src/isPromiseLike.d.ts +3 -7
  112. package/types/src/isQQ.d.ts +2 -5
  113. package/types/src/isSocialCreditCode.d.ts +6 -11
  114. package/types/src/isSwiftCode.d.ts +5 -5
  115. package/types/src/isTWCard.d.ts +7 -4
  116. package/types/src/isTelephone.d.ts +6 -9
  117. package/types/src/isUrl.d.ts +7 -19
  118. package/types/src/isVehicle.d.ts +8 -13
  119. package/types/src/isWX.d.ts +2 -5
  120. package/types/src/minus.d.ts +3 -7
  121. package/types/src/normalizeString.d.ts +2 -0
  122. package/types/src/numberToChinese.d.ts +10 -18
  123. package/types/src/padZero.d.ts +9 -8
  124. package/types/src/parseIdCard.d.ts +3 -3
  125. package/types/src/plus.d.ts +3 -7
  126. package/types/src/randomString.d.ts +2 -0
  127. package/types/src/replaceChar.d.ts +9 -17
  128. package/types/src/round.d.ts +3 -7
  129. package/types/src/safeDate.d.ts +2 -0
  130. package/types/src/setDataURLPrefix.d.ts +2 -0
  131. package/types/src/times.d.ts +3 -7
  132. package/types/src/waitTime.d.ts +3 -1
@@ -1,4 +1,4 @@
1
- import normalizeString from './normalizeString'; // ref: https://github.com/ant-design/ant-design-mobile/blob/v2/components/input-item/index.tsx#L240
1
+ import normalizeString from './normalizeString'; // 参考了: https://github.com/ant-design/ant-design-mobile/blob/v2/components/input-item/index.tsx#L240
2
2
 
3
3
  /**
4
4
  * 计算输入框的值格式化后光标位置
@@ -9,7 +9,7 @@
9
9
  * @returns {Blob} Blob 对象
10
10
  * @example
11
11
  * const dataurl = 'data:text/html;base64,PGEgaWQ9ImEiPjxiIGlkPSJiIj5oZXkhPC9iPjwvYT4=';
12
- * dataURLToBlob(dataurl);
12
+ * dataURLToBlob(dataurl); // Blob {size: 32, type: 'text/html'}
13
13
  */
14
14
  function dataURLToBlob(dataurl) {
15
15
  var arr = dataurl.split(','); // @ts-ignore
package/esm/divide.js CHANGED
@@ -19,6 +19,7 @@ import times from './times';
19
19
  * divide(); // NaN 如果没有传入参数,被除数默认为 undefined 。 Number(undefined) 转换为 NaN ,NaN/1 = NaN
20
20
  * divide(null); // 0 Number(null) 转换为 0 , 0/1 = 0
21
21
  * divide('1.5 ', 0.5); // 3 Number('1.5 ') 转换为 1.5 ,1.5/0.5 = 3
22
+ *
22
23
  */
23
24
 
24
25
  function divide() {
@@ -13,20 +13,16 @@ import normalizeString from './normalizeString';
13
13
  * @example
14
14
  *
15
15
  * // 19位银行卡
16
- * formatBankCard('6228480402564890018');
17
- * // => 6228 4804 0256 4890 018
16
+ * formatBankCard('6228480402564890018'); // 6228 4804 0256 4890 018
18
17
  *
19
18
  * // 16位银行卡
20
- * formatBankCard('6228480402564890');
21
- * // => 6228 4804 0256 4890
19
+ * formatBankCard('6228480402564890'); // 6228 4804 0256 4890
22
20
  *
23
21
  * // 脱敏银行卡
24
- * formatBankCard('6228********890');
25
- * // => 6228 **** **** 890
22
+ * formatBankCard('6228********890'); // 6228 **** **** 890
26
23
  *
27
24
  * // 16位银行卡,"-"间隔
28
- * formatBankCard('6228480402564890', {char: '-'});
29
- * // => 6228-4804-0256-4890
25
+ * formatBankCard('6228480402564890', {char: '-'}); // 6228-4804-0256-4890
30
26
  *
31
27
  */
32
28
 
@@ -10,17 +10,19 @@ import normalizeString from './normalizeString';
10
10
  * @param {string} [options.char=' '] 间隔字符
11
11
  * @returns {string} 格式化后的手机号码
12
12
  * @example
13
- * formatMobile('13345678900') // '133 4567 8900'
14
- * formatMobile('13345678900', { char: '-' }) // '133-4567-8900'
13
+ *
14
+ * formatMobile('13345678900'); // 133 4567 8900
15
+ * formatMobile('13345678900', { char: '-' }); // 133-4567-8900
15
16
  *
16
17
  * // 脱敏手机号码
17
- * formatMobile('133****1234') // '133 **** 1234'
18
- * formatMobile('133****1234', { char: '-' }) // '133-****-1234'
18
+ * formatMobile('133****1234'); // 133 **** 1234
19
+ * formatMobile('133****1234', { char: '-' }); // 133-****-1234
19
20
  *
20
21
  * // 手机号码位数不够
21
- * formatMobile('133') // '133'
22
- * formatMobile('133456') // '133 456'
23
- * formatMobile('13345678') // '133 4567 8'
22
+ * formatMobile('133'); // 133
23
+ * formatMobile('133456'); // 133 456
24
+ * formatMobile('13345678'); // 133 4567 8
25
+ *
24
26
  */
25
27
 
26
28
  function formatMobile(mobileNo) {
@@ -94,32 +94,26 @@ function formatDec(decStr, precision, decimal) {
94
94
  * @example
95
95
  *
96
96
  * // 整数
97
- * formatMoney('1000');
98
- * // => 1,000.00
97
+ * formatMoney('1000'); // 1,000.00
99
98
  *
100
99
  * // 小数(默认保留2位小数)
101
- * formatMoney('3000.03');
102
- * // => 3,000.03
100
+ * formatMoney('3000.03'); // 3,000.03
103
101
  *
104
102
  * // 保留4位小数
105
- * formatMoney('3000.0300', { precision: 4 });
106
- * // => 3,000.0300
103
+ * formatMoney('3000.0300', { precision: 4 }); // 3,000.0300
107
104
  *
108
105
  * // 保留10位小数
109
- * formatMoney('1500.2', { precision: 10 });
110
- * // => 1,500.2000000000
106
+ * formatMoney('1500.2', { precision: 10 }); // 1,500.2000000000
111
107
  *
112
108
  * // 自定义单位符号
113
- * formatMoney(1000.00, { symbol: '$' });
114
- * // => $1,000.00
109
+ * formatMoney(1000.00, { symbol: '$' }); // $1,000.00
115
110
  *
116
111
  * // 自定义千位分割符(默认',')
117
- * formatMoney(1000.00, { thousand: '|' });
118
- * // => 1|000.00
112
+ * formatMoney(1000.00, { thousand: '|' }); // 1|000.00
119
113
  *
120
114
  * // 自定义小数位分割符(默认'.')
121
- * formatMoney(1000.00, { decimal: '&' });
122
- * // => 1,000&00
115
+ * formatMoney(1000.00, { decimal: '&' }); // 1,000&00
116
+ *
123
117
  */
124
118
 
125
119
 
package/esm/isBankCard.js CHANGED
@@ -36,17 +36,12 @@ function sumCheckCode(numStr) {
36
36
  * @returns {boolean} 值是否为银行卡号
37
37
  * @example
38
38
  *
39
- * isBankCard('6228480402564890018');
40
- * // => true
41
- *
42
- * isBankCard('6228480402564890');
43
- * // => true
44
- *
45
- * isBankCard('123456789');
46
- * // => false
47
- *
48
- * isBankCard('123456789', { loose: true });
49
- * // => true
39
+ * isBankCard('6228480402564890018'); // true
40
+ * isBankCard('6228480402564890'); // true
41
+ * isBankCard('123456789'); // false
42
+ *
43
+ * // 宽松模式
44
+ * isBankCard('123456789', { loose: true }); // true
50
45
  *
51
46
  */
52
47
 
@@ -45,17 +45,14 @@ function sumCheckCode(preCode) {
45
45
  * @returns {boolean} 值是否为营业执照号
46
46
  * @example
47
47
  *
48
- * isBusinessLicense('310115600985533');
49
- * // => true
48
+ * isBusinessLicense('310115600985533'); // true
49
+ * isBusinessLicense('310115600985535'); // false
50
50
  *
51
- * isBusinessLicense('310115600985535');
52
- * // => false
53
- *
54
- * isBusinessLicense('310115600985535', { checkCode: false });
55
- * // => true
56
- *
57
- * isBusinessLicense('31011560098', { checkCode: false });
58
- * // => false
51
+ * // 不校验验证码,长度和类型还是有校验
52
+ * isBusinessLicense('310115600985535', { checkCode: false }); // true
53
+ * isBusinessLicense('ac115600985535', { checkCode: false }); // false
54
+ * isBusinessLicense('31011560098', { checkCode: false }); // false
55
+ *
59
56
  */
60
57
 
61
58
 
package/esm/isChinese.js CHANGED
@@ -38,27 +38,20 @@ var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
38
38
  * @returns {boolean} 值是否为中文
39
39
  * @example
40
40
  *
41
- * isChinese('林某某');
42
- * // => true
43
- *
44
- * isChinese('林A');
45
- * // => false
41
+ * isChinese('林某某'); // true
42
+ * isChinese('林A'); // false
46
43
  *
47
44
  * // 宽松模式,只要包含中文即为true
48
- * isChinese('林A', { loose: true });
49
- * // => true
50
- *
51
- * isChinese('A林A', { loose: true });
52
- * // => true
53
- *
54
- * isChinese('𠮷');
55
- * // => false
45
+ * isChinese('林A', { loose: true }); // true
46
+ * isChinese('A林A', { loose: true }); // true
56
47
  *
48
+ * // 扩展字符集的字符
49
+ * isChinese('𠮷'); // false
50
+ *
57
51
  * // 使用中文扩展字符集,需要浏览器支持 RegExp.prototype.unicode 才生效。
58
- * isChinese('𠮷', { useExtend: true });
59
- * // => true
60
- * isChinese('𠮷aa', { useExtend: true, loose: true });
61
- * // => true
52
+ * isChinese('𠮷', { useExtend: true }); // true
53
+ * isChinese('𠮷aa', { useExtend: true, loose: true }); // true
54
+ *
62
55
  */
63
56
 
64
57
  function isChinese(value) {
package/esm/isEmail.js CHANGED
@@ -11,11 +11,8 @@ var reg = /^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})
11
11
  * @returns {boolean} 值是否为Email
12
12
  * @example
13
13
  *
14
- * isEmail('1232@qq.com');
15
- * // => true
16
- *
17
- * isEmail('123@');
18
- * // => false
14
+ * isEmail('1232@qq.com'); // true
15
+ * isEmail('123@'); // false
19
16
  *
20
17
  */
21
18
 
package/esm/isHMCard.js CHANGED
@@ -12,16 +12,16 @@ var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
12
12
  * @returns {boolean} 是否为港澳居民来往内地通行证
13
13
  * @example
14
14
  * // 第一代 11 位
15
- * isHMCard('h3203117707') // true
16
- * isHMCard('H3203117707') // true
17
- * isHMCard('m3203117707') // true
18
- * isHMCard('M3203117707') // true
15
+ * isHMCard('h3203117707'); // true
16
+ * isHMCard('H3203117707'); // true
17
+ * isHMCard('m3203117707'); // true
18
+ * isHMCard('M3203117707'); // true
19
19
  *
20
20
  * // 第二代 9 位
21
- * isHMCard('h32031177') // true
22
- * isHMCard('H32031177') // true
23
- * isHMCard('m32031177') // true
24
- * isHMCard('M32031177') // true
21
+ * isHMCard('h32031177'); // true
22
+ * isHMCard('H32031177'); // true
23
+ * isHMCard('m32031177'); // true
24
+ * isHMCard('M32031177'); // true
25
25
  */
26
26
 
27
27
  function isHMCard(value) {
package/esm/isIPv4.js CHANGED
@@ -11,17 +11,10 @@ var reg = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-
11
11
  * @returns {boolean} 值是否为ipv4
12
12
  * @example
13
13
  *
14
- * isIPv4('192.168.1.1');
15
- * // => true
16
- *
17
- * isIPv4('255.255.255.255');
18
- * // => true
19
- *
20
- * isIPv4('256.256.256.256');
21
- * // => false
22
- *
23
- * isIPv4('0.0');
24
- * // => false
14
+ * isIPv4('192.168.1.1'); // true
15
+ * isIPv4('255.255.255.255'); // true
16
+ * isIPv4('256.256.256.256'); // false
17
+ * isIPv4('0.0'); // false
25
18
  *
26
19
  */
27
20
 
package/esm/isIPv6.js CHANGED
@@ -12,41 +12,23 @@ var reg = /^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-
12
12
  * @example
13
13
  *
14
14
  * // 冒分十六进制表示法
15
- * isIPv6('2001:0DB8:0000:0023:0008:0800:200C:417A');
16
- * // => true
15
+ * isIPv6('2001:0DB8:0000:0023:0008:0800:200C:417A'); // true
17
16
  *
18
17
  * // 前导0省略
19
- * isIPv6('2001:DB8:0:23:8:800:200C:417A');
20
- * // => true
21
- *
22
- * isIPv6('FF01:0:0:0:0:0:0:1101');
23
- * // => true
18
+ * isIPv6('2001:DB8:0:23:8:800:200C:417A'); // true
19
+ * isIPv6('FF01:0:0:0:0:0:0:1101'); // true
24
20
  *
25
21
  * // 0位压缩表示法
26
- * isIPv6('FF01::1101');
27
- * // => true
28
- *
29
- * isIPv6('::1');
30
- * // => true
31
- *
32
- * isIPv6('::');
33
- * // => true
34
- *
35
- * isIPv6('0:0:0:0:0:0:0:1');
36
- * // => true
37
- *
38
- * isIPv6('0:0:0:0:0:0:0:0');
39
- * // => true
22
+ * isIPv6('FF01::1101'); // true
23
+ * isIPv6('::1'); // true
24
+ * isIPv6('::'); // true
25
+ * isIPv6('0:0:0:0:0:0:0:1'); // true
26
+ * isIPv6('0:0:0:0:0:0:0:0'); // true
40
27
  *
41
28
  * // 内嵌IPv4地址表示法
42
- * isIPv6('::192.168.1.1');
43
- * // => true
44
- *
45
- * isIPv6('::FFFF:192.168.1.1');
46
- * // => true
47
- *
48
- * isIPv6('192.168.1.1');
49
- * // => false
29
+ * isIPv6('::192.168.1.1'); // true
30
+ * isIPv6('::FFFF:192.168.1.1'); // true
31
+ * isIPv6('192.168.1.1'); // false
50
32
  *
51
33
  */
52
34
 
package/esm/isIdCard.js CHANGED
@@ -39,20 +39,17 @@ function check(id) {
39
39
  * @returns {boolean} 值是否为身份证号
40
40
  * @example
41
41
  *
42
- * isIdCard('130701199310302288');
43
- * // => true
42
+ * isIdCard('130701199310302288'); // true
43
+ * isIdCard('13070119931030228X'); // false
44
44
  *
45
- * isIdCard('13070119931030228X');
46
- * // => false
45
+ * // 不校验校验码
46
+ * isIdCard('13070119931030228X', { checkCode: false }); // true
47
47
  *
48
- * isIdCard('13070119931030228X', { checkCode: false }); // 不校验校验码
49
- * // => true
50
- *
51
- * isIdCard('320311770706001');
52
- * // => false
53
- *
54
- * isIdCard('320311770706001', { loose: true });
55
- * // => true
48
+ * // 默认不支持15位身份证号码
49
+ * isIdCard('320311770706001'); // false
50
+ *
51
+ * // 宽松模式,支持15位身份证号
52
+ * isIdCard('320311770706001', { loose: true }); // true
56
53
  *
57
54
  */
58
55
 
package/esm/isMobile.js CHANGED
@@ -11,11 +11,8 @@ var reg = /^1[3456789]\d{9}$/;
11
11
  * @returns {boolean} 值是否为手机号码
12
12
  * @example
13
13
  *
14
- * isMobile('13000000000');
15
- * // => true
16
- *
17
- * isMobile('13000');
18
- * // => false
14
+ * isMobile('13000000000'); // true
15
+ * isMobile('13000'); // false
19
16
  *
20
17
  */
21
18
 
package/esm/isPassport.js CHANGED
@@ -13,11 +13,8 @@ var reg = /^((e[\da-z])|(de)|(se)|(pe)|([khm][\da-z]))[\da-z]{7}$/i;
13
13
  * @returns {boolean} 值是否为护照号
14
14
  * @example
15
15
  *
16
- * isPassport('E12345678');
17
- * // => true
18
- *
19
- * isPassport('abc');
20
- * // => false
16
+ * isPassport('E12345678'); // true
17
+ * isPassport('abc'); // false
21
18
  *
22
19
  */
23
20
 
package/esm/isPassword.js CHANGED
@@ -17,27 +17,20 @@ import validatePassword from './validatePassword';
17
17
  * @returns {boolean} 值是否符合密码强度
18
18
  * @example
19
19
  *
20
- * isPassword('a12345678');
21
- * // => true
22
- *
23
- * isPassword('a12345678', {level: 3});
24
- * // => false
25
- *
26
- * isPassword('Aa12345678', {level: 3});
27
- * // => true
28
- *
29
- * isPassword('Aa12345678', {level: 3, ignoreCase: true});
30
- * // => false
31
- *
32
- * isPassword('_Aa12345678', {level: 3, ignoreCase: true});
33
- * // => true
34
- *
35
- * // 仅支持 数字、字母、特殊字符,其他字符如中文字符是校验不通过的
36
- * isPassword('_Aa一二三45678', {level: 3, ignoreCase: true});
37
- * // => false
38
- *
39
- * isPassword(' _Aa12345678', {level: 3, ignoreCase: true});
40
- * // => false
20
+ * isPassword('a12345678'); // true
21
+ *
22
+ * // 3级密码强度
23
+ * isPassword('a12345678', {level: 3}); // false
24
+ * isPassword('Aa12345678', {level: 3}); // true
25
+ *
26
+ * // 3级密码强度,大小写字符仅计算1级强度
27
+ * isPassword('Aa12345678', {level: 3, ignoreCase: true}); // false
28
+ * isPassword('_Aa12345678', {level: 3, ignoreCase: true}); // true
29
+ *
30
+ * // 仅支持 数字、字母、特殊字符,其他非法字符如中文字符是校验不通过的
31
+ * isPassword('_Aa一二三45678', {level: 3, ignoreCase: true}); // false
32
+ * isPassword(' _Aa12345678', {level: 3, ignoreCase: true}); // false
33
+ *
41
34
  */
42
35
 
43
36
  function isPassword(value) {
package/esm/isPostcode.js CHANGED
@@ -11,11 +11,8 @@ var reg = /^\d{6}$/;
11
11
  * @returns {boolean} 值是否为邮政编码
12
12
  * @example
13
13
  *
14
- * isPostcode('101111');
15
- * // => true
16
- *
17
- * isPostcode('123');
18
- * // => false
14
+ * isPostcode('101111'); // true
15
+ * isPostcode('123'); // false
19
16
  *
20
17
  */
21
18
 
@@ -10,14 +10,10 @@ import _typeof from "@babel/runtime/helpers/typeof";
10
10
  * @returns {boolean} 是否类似Promise对象
11
11
  * @example
12
12
  *
13
- * isPromiseLike([]);
14
- * => false
15
- *
16
- * isPromiseLike({then:()=>{}});
17
- * => true
18
- *
19
- * isPromiseLike(Promise.resolve());
20
- * => true
13
+ * isPromiseLike([]); // false
14
+ * isPromiseLike({ then: () => { } }); // true
15
+ * isPromiseLike(Promise.resolve()); // true
16
+ *
21
17
  */
22
18
  function isPromiseLike(obj) {
23
19
  return obj !== null && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
package/esm/isQQ.js CHANGED
@@ -11,11 +11,8 @@ var reg = /^[1-9]\d{4,10}$/;
11
11
  * @returns {boolean} 值是否为QQ号
12
12
  * @example
13
13
  *
14
- * isQQ('12345');
15
- * // => true
16
- *
17
- * isQQ('123');
18
- * // => false
14
+ * isQQ('12345'); // true
15
+ * isQQ('123'); // false
19
16
  *
20
17
  */
21
18
 
@@ -49,18 +49,13 @@ function sumCheckCode(preCode) {
49
49
  * @returns {boolean} 值是否为统一社会信用代码
50
50
  * @example
51
51
  *
52
- * isSocialCreditCode('91350100M000100Y43');
53
- * // => true
52
+ * isSocialCreditCode('91350100M000100Y43'); // true
53
+ * isSocialCreditCode('91350100M000100Y4A'); // false
54
54
  *
55
- * isSocialCreditCode('91350100M000100Y4A');
56
- * // => false
57
- *
58
- * // 不校验校验位
59
- * isSocialCreditCode('91350100M000100Y4A', { checkCode: false });
60
- * // => true
61
- *
62
- * isSocialCreditCode('91350100M000100Y', { checkCode: false });
63
- * // => false
55
+ * // 不校验校验位,长度和类型还是有校验的
56
+ * isSocialCreditCode('91350100M000100Y4A', { checkCode: false }); // true
57
+ * isSocialCreditCode('91350100M000100YIO', { checkCode: false }); // false
58
+ * isSocialCreditCode('91350100M000100Y', { checkCode: false }); // false
64
59
  *
65
60
  */
66
61
 
@@ -11,13 +11,13 @@ var reg = /^[A-Z]{6}[A-Z\d]{2}(?:[A-Z\d]{3})?$/;
11
11
  * @returns {boolean} 值是否为 Swift Code
12
12
  * @example
13
13
  *
14
- * isSwiftCode('DEUTDEFF') // true
15
- * isSwiftCode('deutdeff') // false
14
+ * isSwiftCode('DEUTDEFF'); // true
15
+ * isSwiftCode('deutdeff'); // false
16
16
  *
17
- * isSwiftCode('BKTWTWTP010') // true
18
- * isSwiftCode('010BKTWTWTP') // false
17
+ * isSwiftCode('BKTWTWTP010'); // true
18
+ * isSwiftCode('010BKTWTWTP'); // false
19
19
  *
20
- * isSwiftCode('ICBKCNBJBJM') // true
20
+ * isSwiftCode('ICBKCNBJBJM'); // true
21
21
  *
22
22
  */
23
23
 
package/esm/isTWCard.js CHANGED
@@ -15,12 +15,15 @@ var singleRegTWCard = /^[\da-z]{10,12}$/i;
15
15
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,表示支持一次性短期通行证
16
16
  * @returns {boolean} 是否为台湾居民来往大陆通行证
17
17
  * @example
18
- * isTWCard('12345678') // true
19
- * isTWCard('07257456') // true
18
+ *
19
+ * isTWCard('12345678'); // true
20
+ * isTWCard('07257456'); // true
20
21
  *
21
22
  * // 一次性短期
22
- * isTWCard('F290299977') // false
23
- * isTWCard('F290299977', { loose: true }) // true
23
+ * isTWCard('F290299977'); // false
24
+ *
25
+ * // 宽松模式,支持一次性短期通行证
26
+ * isTWCard('F290299977', { loose: true }); // true
24
27
  */
25
28
 
26
29
  function isTWCard(value) {
@@ -11,17 +11,14 @@ var reg = /^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;
11
11
  * @returns {boolean} 值是否为固定电话
12
12
  * @example
13
13
  *
14
- * isTelephone('22033212');
15
- * // => true
14
+ * isTelephone('22033212'); // true
15
+ * isTelephone('13000000000'); // false
16
+ *
17
+ * // 含区号
18
+ * isTelephone('021-22033212'); // true
16
19
  *
17
- * isTelephone('021-22033212');
18
- * // => true
19
- *
20
- * isTelephone('021-22033212-123');
21
- * // => true
22
- *
23
- * isTelephone('13000000000');
24
- * // => false
20
+ * // 含区号和分机号
21
+ * isTelephone('021-22033212-123'); // true
25
22
  *
26
23
  */
27
24
 
package/esm/isUrl.js CHANGED
@@ -12,26 +12,14 @@ var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:
12
12
  * @returns {boolean} 值是否为url
13
13
  * @example
14
14
  *
15
- * isUrl('');
16
- * // => false
17
- *
18
- * isUrl('8.8.8.8');
19
- * // => false
20
- *
21
- * isUrl('example.com');
22
- * // => true
23
- *
24
- * isUrl('http://example.com');
25
- * // => true
26
- *
27
- * isUrl('https://example.com:8080');
28
- * // => true
29
- *
30
- * isUrl('http://www.example.com/test/123');
31
- * // => true
32
- *
33
- * isUrl('http://www.example.com/test/123?foo=bar');
34
- * // => true
15
+ * isUrl(''); // false
16
+ * isUrl('8.8.8.8'); // false
17
+ * isUrl('example.com'); // true
18
+ * isUrl('http://example.com'); // true
19
+ * isUrl('https://example.com:8080'); // true
20
+ * isUrl('http://www.example.com/test/123'); // true
21
+ * isUrl('http://www.example.com/test/123?foo=bar'); // true
22
+ *
35
23
  */
36
24
 
37
25
  function isUrl(value) {
package/esm/isVehicle.js CHANGED
@@ -12,20 +12,15 @@ var reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕
12
12
  * @returns {boolean} 值是否为车牌号
13
13
  * @example
14
14
  *
15
- * isVehicle('京L12345');
16
- * // => true
17
- *
18
- * isVehicle('粤BD12345');
19
- * // => true
20
- *
21
- * isVehicle('粤BF12345');
22
- * // => true
23
- *
24
- * isVehicle('粤B12345D');
25
- * // => true
26
- *
27
- * isVehicle('粤B12345F');
28
- * // => true
15
+ * isVehicle('京L12345'); // true
16
+ * isVehicle('京L1234学'); // true
17
+ * isVehicle('BL1234警'); // true
18
+ *
19
+ * // 新能源车牌
20
+ * isVehicle('粤BD12345'); // true
21
+ * isVehicle('粤BF12345'); // true
22
+ * isVehicle('粤B12345D'); // true
23
+ * isVehicle('粤B12345F'); // true
29
24
  *
30
25
  */
31
26
 
package/esm/isWX.js CHANGED
@@ -11,11 +11,8 @@ var reg = /^[a-z]([-_a-z0-9]{5,19})+$/i;
11
11
  * @returns {boolean} 值是否为微信号
12
12
  * @example
13
13
  *
14
- * isWX('a12345');
15
- * // => true
16
- *
17
- * isWX('123');
18
- * // => false
14
+ * isWX('a12345'); // true
15
+ * isWX('123'); // false
19
16
  *
20
17
  */
21
18