util-helpers 4.10.3 → 4.11.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.
- package/dist/util-helpers.js +171 -133
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/bytesToSize.js +4 -3
- package/esm/formatMoney.js +7 -10
- package/esm/isBusinessLicense.js +2 -2
- package/esm/isChinese.js +24 -11
- package/esm/numberToChinese.js +30 -36
- package/esm/parseIdCard.js +9 -24
- package/esm/replaceChar.js +8 -7
- package/esm/round.js +8 -0
- package/esm/utils/devWarn.js +16 -0
- package/esm/utils/math.util.js +52 -29
- package/esm/validatePassword.js +25 -20
- package/lib/bytesToSize.js +4 -3
- package/lib/formatMoney.js +7 -10
- package/lib/isBusinessLicense.js +2 -2
- package/lib/isChinese.js +24 -11
- package/lib/numberToChinese.js +32 -36
- package/lib/parseIdCard.js +9 -24
- package/lib/replaceChar.js +11 -8
- package/lib/round.js +9 -0
- package/lib/utils/devWarn.js +24 -0
- package/lib/utils/math.util.js +54 -29
- package/lib/validatePassword.js +27 -20
- package/package.json +3 -2
- package/types/isChinese.d.ts +13 -3
- package/types/replaceChar.d.ts +1 -1
- package/types/utils/devWarn.d.ts +7 -0
- package/types/utils/math.util.d.ts +2 -2
- package/types/validatePassword.d.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "util-helpers",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "一个基于业务场景的工具方法库",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "jest --verbose",
|
|
11
|
+
"test:coverage": "jest --coverage",
|
|
11
12
|
"test:math": "jest --verbose test/math",
|
|
12
13
|
"test:type": "jest --verbose test/type",
|
|
13
14
|
"test:validator": "jest --verbose test/validator",
|
|
14
15
|
"test:processor": "jest --verbose test/processor",
|
|
15
|
-
"build": "npm
|
|
16
|
+
"build": "npm run build:lib && npm run build:esm && npm run build:dist && npm run types",
|
|
16
17
|
"build:lib": "rm -rf lib && cross-env MODULE_TYPE=cjs babel src --out-dir lib",
|
|
17
18
|
"build:esm": "rm -rf esm && cross-env MODULE_TYPE=esm babel src --out-dir esm",
|
|
18
19
|
"build:dist": "rm -rf dist && rollup -c",
|
package/types/isChinese.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export default isChinese;
|
|
|
9
9
|
* @param {*} value 要检测的值
|
|
10
10
|
* @param {Object} [options] 配置项
|
|
11
11
|
* @param {boolean} [options.loose=false] 宽松模式。如果为true,只要包含中文即为true
|
|
12
|
+
* @param {boolean} [options.useExtend=false] 使用统一表意文字扩展A-F。注意:如果不支持 `RegExp.prototype.unicode`,扩展字符集将自动不生效,如IE浏览器。
|
|
12
13
|
* @returns {boolean} 值是否为中文
|
|
13
14
|
* @example
|
|
14
15
|
*
|
|
@@ -19,13 +20,22 @@ export default isChinese;
|
|
|
19
20
|
* // => false
|
|
20
21
|
*
|
|
21
22
|
* // 宽松模式,只要包含中文即为true
|
|
22
|
-
* isChinese('林A', {loose: true});
|
|
23
|
+
* isChinese('林A', { loose: true });
|
|
23
24
|
* // => true
|
|
24
25
|
*
|
|
25
|
-
* isChinese('A林A', {loose: true});
|
|
26
|
+
* isChinese('A林A', { loose: true });
|
|
26
27
|
* // => true
|
|
27
28
|
*
|
|
29
|
+
* isChinese('𠮷');
|
|
30
|
+
* // => false
|
|
31
|
+
*
|
|
32
|
+
* // 使用中文扩展字符集,需要浏览器支持 RegExp.prototype.unicode 才生效。
|
|
33
|
+
* isChinese('𠮷', { useExtend: true });
|
|
34
|
+
* // => true
|
|
35
|
+
* isChinese('𠮷aa', { useExtend: true, loose: true });
|
|
36
|
+
* // => true
|
|
28
37
|
*/
|
|
29
|
-
declare function isChinese(value: any, { loose }?: {
|
|
38
|
+
declare function isChinese(value: any, { loose, useExtend }?: {
|
|
30
39
|
loose?: boolean | undefined;
|
|
40
|
+
useExtend?: boolean | undefined;
|
|
31
41
|
} | undefined): boolean;
|
package/types/replaceChar.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export default replaceChar;
|
|
|
45
45
|
* // => 林**
|
|
46
46
|
*
|
|
47
47
|
*/
|
|
48
|
-
declare function replaceChar(str
|
|
48
|
+
declare function replaceChar(str: string, { start, end, char, repeat, exclude }?: {
|
|
49
49
|
start?: number | undefined;
|
|
50
50
|
end?: number | undefined;
|
|
51
51
|
char?: string | undefined;
|
|
@@ -51,6 +51,6 @@ export function trimLeftZero(num: string): string;
|
|
|
51
51
|
* 2.小数点前边是0,小数点后十分位(包含十分位)之后连续零的个数大于等于6个
|
|
52
52
|
*
|
|
53
53
|
* @param {string | number} num 科学计数法数字
|
|
54
|
-
* @returns {string} 转换后的数字字符串
|
|
54
|
+
* @returns {string | number} 转换后的数字字符串
|
|
55
55
|
*/
|
|
56
|
-
export function scientificToNumber(num: string | number): string;
|
|
56
|
+
export function scientificToNumber(num: string | number): string | number;
|
|
@@ -84,7 +84,7 @@ export type ValidatePasswordReturn = {
|
|
|
84
84
|
* }
|
|
85
85
|
* }
|
|
86
86
|
*
|
|
87
|
-
* validatePassword('a12345678', {level: 3});
|
|
87
|
+
* validatePassword('a12345678', { level: 3 });
|
|
88
88
|
* // =>
|
|
89
89
|
* {
|
|
90
90
|
* validated: false,
|
|
@@ -98,7 +98,7 @@ export type ValidatePasswordReturn = {
|
|
|
98
98
|
* }
|
|
99
99
|
* }
|
|
100
100
|
*
|
|
101
|
-
* validatePassword('_Aa一二三45678', {level: 3, ignoreCase: true});
|
|
101
|
+
* validatePassword('_Aa一二三45678', { level: 3, ignoreCase: true });
|
|
102
102
|
* // =>
|
|
103
103
|
* {
|
|
104
104
|
* validated: false,
|
|
@@ -113,7 +113,7 @@ export type ValidatePasswordReturn = {
|
|
|
113
113
|
* }
|
|
114
114
|
*
|
|
115
115
|
* // 自定义特殊字符
|
|
116
|
-
* validatePassword('_Aa一二三45678', {level: 3, ignoreCase: true, special: '_一二三'});
|
|
116
|
+
* validatePassword('_Aa一二三45678', { level: 3, ignoreCase: true, special: '_一二三' });
|
|
117
117
|
* // =>
|
|
118
118
|
* {
|
|
119
119
|
* validated: true,
|