@daysnap/utils 0.0.56 → 0.0.58
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/docs/modules.md +313 -90
- package/es/filterIdCard.d.ts +1 -0
- package/es/filterIdCard.js +1 -0
- package/es/formatDateStr.d.ts +1 -0
- package/es/formatDateStr.js +1 -0
- package/es/getRandom.d.ts +6 -0
- package/es/getRandom.js +11 -0
- package/es/getRandomNumber.d.ts +5 -0
- package/es/getRandomNumber.js +8 -0
- package/es/index.d.ts +10 -1
- package/es/index.js +10 -1
- package/es/isAmount.d.ts +11 -0
- package/es/isAmount.js +13 -0
- package/es/isChinese.d.ts +4 -0
- package/es/isChinese.js +6 -0
- package/es/isEmptyObject.d.ts +2 -2
- package/es/isEmptyObject.js +3 -3
- package/es/isIE.d.ts +6 -0
- package/es/isIE.js +27 -0
- package/es/isWeChat.d.ts +9 -0
- package/es/isWeChat.js +13 -0
- package/es/isWeChatMiniProgram.d.ts +5 -0
- package/es/isWeChatMiniProgram.js +8 -0
- package/es/parseQuery.js +1 -1
- package/es/scrollToTop.d.ts +4 -0
- package/es/scrollToTop.js +10 -0
- package/es/stringifyQuery.d.ts +1 -1
- package/es/stringifyQuery.js +1 -1
- package/es/toCDB.d.ts +4 -0
- package/es/toCDB.js +19 -0
- package/es/toDBC.d.ts +4 -0
- package/es/toDBC.js +19 -0
- package/lib/filterIdCard.d.ts +1 -0
- package/lib/filterIdCard.js +1 -0
- package/lib/formatDateStr.d.ts +1 -0
- package/lib/formatDateStr.js +1 -0
- package/lib/getRandom.d.ts +6 -0
- package/lib/getRandom.js +15 -0
- package/lib/getRandomNumber.d.ts +5 -0
- package/lib/getRandomNumber.js +12 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +10 -1
- package/lib/isAmount.d.ts +11 -0
- package/lib/isAmount.js +17 -0
- package/lib/isChinese.d.ts +4 -0
- package/lib/isChinese.js +10 -0
- package/lib/isEmptyObject.d.ts +2 -2
- package/lib/isEmptyObject.js +3 -3
- package/lib/isIE.d.ts +6 -0
- package/lib/isIE.js +31 -0
- package/lib/isWeChat.d.ts +9 -0
- package/lib/isWeChat.js +18 -0
- package/lib/isWeChatMiniProgram.d.ts +5 -0
- package/lib/isWeChatMiniProgram.js +12 -0
- package/lib/parseQuery.js +1 -1
- package/lib/scrollToTop.d.ts +4 -0
- package/lib/scrollToTop.js +14 -0
- package/lib/stringifyQuery.d.ts +1 -1
- package/lib/stringifyQuery.js +1 -1
- package/lib/toCDB.d.ts +4 -0
- package/lib/toCDB.js +23 -0
- package/lib/toDBC.d.ts +4 -0
- package/lib/toDBC.js +23 -0
- package/package.json +1 -1
- package/es/isWeixin.d.ts +0 -4
- package/es/isWeixin.js +0 -6
- package/lib/isWeixin.d.ts +0 -4
- package/lib/isWeixin.js +0 -10
package/es/filterIdCard.d.ts
CHANGED
package/es/filterIdCard.js
CHANGED
package/es/formatDateStr.d.ts
CHANGED
package/es/formatDateStr.js
CHANGED
package/es/getRandom.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成一个随机字符串
|
|
3
|
+
* @param length 生成随机字符串的长度
|
|
4
|
+
* @param alphabet 字母表
|
|
5
|
+
*/
|
|
6
|
+
export function getRandom(length, alphabet = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM') {
|
|
7
|
+
return new Array(length)
|
|
8
|
+
.fill('')
|
|
9
|
+
.map(() => alphabet[Math.floor(Math.random() * alphabet.length)])
|
|
10
|
+
.join('');
|
|
11
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -25,21 +25,26 @@ export * from './formatPathParams';
|
|
|
25
25
|
export * from './getBlobByUrl';
|
|
26
26
|
export * from './getDayMillisecond';
|
|
27
27
|
export * from './getImageInfo';
|
|
28
|
+
export * from './getRandom';
|
|
28
29
|
export * from './getRandomColor';
|
|
30
|
+
export * from './getRandomNumber';
|
|
29
31
|
export * from './getVideoInfo';
|
|
30
32
|
export * from './inBrowser';
|
|
31
33
|
export * from './insertLink';
|
|
32
34
|
export * from './insertScript';
|
|
33
35
|
export * from './insertStyle';
|
|
36
|
+
export * from './isAmount';
|
|
34
37
|
export * from './isAndroid';
|
|
35
38
|
export * from './isArray';
|
|
36
39
|
export * from './isBoolean';
|
|
40
|
+
export * from './isChinese';
|
|
37
41
|
export * from './isDate';
|
|
38
42
|
export * from './isEmail';
|
|
39
43
|
export * from './isEmpty';
|
|
40
44
|
export * from './isEmptyObject';
|
|
41
45
|
export * from './isError';
|
|
42
46
|
export * from './isFunction';
|
|
47
|
+
export * from './isIE';
|
|
43
48
|
export * from './isIOS';
|
|
44
49
|
export * from './isIdCard';
|
|
45
50
|
export * from './isJSONString';
|
|
@@ -55,7 +60,8 @@ export * from './isRegExp';
|
|
|
55
60
|
export * from './isString';
|
|
56
61
|
export * from './isURL';
|
|
57
62
|
export * from './isUndefined';
|
|
58
|
-
export * from './
|
|
63
|
+
export * from './isWeChat';
|
|
64
|
+
export * from './isWeChatMiniProgram';
|
|
59
65
|
export * from './isWindow';
|
|
60
66
|
export * from './kebabCase';
|
|
61
67
|
export * from './mousewheel';
|
|
@@ -73,10 +79,13 @@ export * from './replaceCrlf';
|
|
|
73
79
|
export * from './reserve';
|
|
74
80
|
export * from './rgbToHex';
|
|
75
81
|
export * from './round';
|
|
82
|
+
export * from './scrollToTop';
|
|
76
83
|
export * from './sleep';
|
|
77
84
|
export * from './splitArray';
|
|
78
85
|
export * from './storage';
|
|
79
86
|
export * from './stringTrim';
|
|
80
87
|
export * from './stringifyQuery';
|
|
81
88
|
export * from './throttle';
|
|
89
|
+
export * from './toCDB';
|
|
90
|
+
export * from './toDBC';
|
|
82
91
|
export * from './typeOf';
|
package/es/index.js
CHANGED
|
@@ -26,21 +26,26 @@ export * from './formatPathParams';
|
|
|
26
26
|
export * from './getBlobByUrl';
|
|
27
27
|
export * from './getDayMillisecond';
|
|
28
28
|
export * from './getImageInfo';
|
|
29
|
+
export * from './getRandom';
|
|
29
30
|
export * from './getRandomColor';
|
|
31
|
+
export * from './getRandomNumber';
|
|
30
32
|
export * from './getVideoInfo';
|
|
31
33
|
export * from './inBrowser';
|
|
32
34
|
export * from './insertLink';
|
|
33
35
|
export * from './insertScript';
|
|
34
36
|
export * from './insertStyle';
|
|
37
|
+
export * from './isAmount';
|
|
35
38
|
export * from './isAndroid';
|
|
36
39
|
export * from './isArray';
|
|
37
40
|
export * from './isBoolean';
|
|
41
|
+
export * from './isChinese';
|
|
38
42
|
export * from './isDate';
|
|
39
43
|
export * from './isEmail';
|
|
40
44
|
export * from './isEmpty';
|
|
41
45
|
export * from './isEmptyObject';
|
|
42
46
|
export * from './isError';
|
|
43
47
|
export * from './isFunction';
|
|
48
|
+
export * from './isIE';
|
|
44
49
|
export * from './isIOS';
|
|
45
50
|
export * from './isIdCard';
|
|
46
51
|
export * from './isJSONString';
|
|
@@ -56,7 +61,8 @@ export * from './isRegExp';
|
|
|
56
61
|
export * from './isString';
|
|
57
62
|
export * from './isURL';
|
|
58
63
|
export * from './isUndefined';
|
|
59
|
-
export * from './
|
|
64
|
+
export * from './isWeChat';
|
|
65
|
+
export * from './isWeChatMiniProgram';
|
|
60
66
|
export * from './isWindow';
|
|
61
67
|
export * from './kebabCase';
|
|
62
68
|
export * from './mousewheel';
|
|
@@ -74,10 +80,13 @@ export * from './replaceCrlf';
|
|
|
74
80
|
export * from './reserve';
|
|
75
81
|
export * from './rgbToHex';
|
|
76
82
|
export * from './round';
|
|
83
|
+
export * from './scrollToTop';
|
|
77
84
|
export * from './sleep';
|
|
78
85
|
export * from './splitArray';
|
|
79
86
|
export * from './storage';
|
|
80
87
|
export * from './stringTrim';
|
|
81
88
|
export * from './stringifyQuery';
|
|
82
89
|
export * from './throttle';
|
|
90
|
+
export * from './toCDB';
|
|
91
|
+
export * from './toDBC';
|
|
83
92
|
export * from './typeOf';
|
package/es/isAmount.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是合法金额
|
|
3
|
+
* 只能是数字,小数点后只能保留两位或一位
|
|
4
|
+
* isAmount(0) => true
|
|
5
|
+
* isAmount('01') => false
|
|
6
|
+
* isAmount('1.') => true
|
|
7
|
+
* isAmount('1.1') => true
|
|
8
|
+
* isAmount('1.12') => true
|
|
9
|
+
* isAmount('1.123') => false
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAmount(val: string): boolean;
|
package/es/isAmount.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是合法金额
|
|
3
|
+
* 只能是数字,小数点后只能保留两位或一位
|
|
4
|
+
* isAmount(0) => true
|
|
5
|
+
* isAmount('01') => false
|
|
6
|
+
* isAmount('1.') => true
|
|
7
|
+
* isAmount('1.1') => true
|
|
8
|
+
* isAmount('1.12') => true
|
|
9
|
+
* isAmount('1.123') => false
|
|
10
|
+
*/
|
|
11
|
+
export function isAmount(val) {
|
|
12
|
+
return /^([1-9]\d*|0)([.]?|(\.\d{1,2})?)$/.test(val);
|
|
13
|
+
}
|
package/es/isChinese.js
ADDED
package/es/isEmptyObject.d.ts
CHANGED
package/es/isEmptyObject.js
CHANGED
package/es/isIE.d.ts
ADDED
package/es/isIE.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断浏览器是否是 ie
|
|
3
|
+
* 如果是 ie 则会返回对应 ie 版本
|
|
4
|
+
* 如果不是则返回false
|
|
5
|
+
*/
|
|
6
|
+
export function isIE() {
|
|
7
|
+
const ua = window.navigator.userAgent;
|
|
8
|
+
const msie = ua.indexOf('MSIE ');
|
|
9
|
+
if (msie > 0) {
|
|
10
|
+
// IE 10 or older => return version number
|
|
11
|
+
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
|
12
|
+
}
|
|
13
|
+
const trident = ua.indexOf('Trident/');
|
|
14
|
+
if (trident > 0) {
|
|
15
|
+
// IE 11 => return version number
|
|
16
|
+
const rv = ua.indexOf('rv:');
|
|
17
|
+
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
|
|
18
|
+
}
|
|
19
|
+
// https://learn.microsoft.com/zh-cn/microsoft-edge/web-platform/user-agent-guidance
|
|
20
|
+
// https://learn.microsoft.com/zh-cn/microsoft-edge/web-platform/user-agent-guidance#microsoft-edge-legacy
|
|
21
|
+
const edge = ua.indexOf('Edge/');
|
|
22
|
+
if (edge > 0) {
|
|
23
|
+
// Edge (IE 12+) => return version number
|
|
24
|
+
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
package/es/isWeChat.d.ts
ADDED
package/es/isWeChat.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是微信小程序web-view环境
|
|
3
|
+
* https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html
|
|
4
|
+
*/
|
|
5
|
+
export function isWeChatMiniProgram() {
|
|
6
|
+
// 从微信7.0.0开始,可以通过判断userAgent中包含miniProgram字样来判断小程序web-view环境。
|
|
7
|
+
return window.navigator.userAgent.toLocaleLowerCase().includes('miniprogram');
|
|
8
|
+
}
|
package/es/parseQuery.js
CHANGED
|
@@ -10,7 +10,7 @@ export function parseQuery(v, k) {
|
|
|
10
10
|
searchStr = window.location.search;
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
const url = new URL(v
|
|
13
|
+
const url = new URL(v);
|
|
14
14
|
searchStr = url.search;
|
|
15
15
|
}
|
|
16
16
|
const query = new URLSearchParams(decodeURIComponent(searchStr));
|
package/es/stringifyQuery.d.ts
CHANGED
package/es/stringifyQuery.js
CHANGED
package/es/toCDB.d.ts
ADDED
package/es/toCDB.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全角转换为半角
|
|
3
|
+
*/
|
|
4
|
+
export function toCDB(str) {
|
|
5
|
+
let result = '';
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
const code = str.charCodeAt(i);
|
|
8
|
+
if (code >= 65281 && code <= 65374) {
|
|
9
|
+
result += String.fromCharCode(str.charCodeAt(i) - 65248);
|
|
10
|
+
}
|
|
11
|
+
else if (code == 12288) {
|
|
12
|
+
result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
result += str.charAt(i);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
package/es/toDBC.d.ts
ADDED
package/es/toDBC.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 半角转换为全角
|
|
3
|
+
*/
|
|
4
|
+
export function toDBC(str) {
|
|
5
|
+
let result = '';
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
const code = str.charCodeAt(i);
|
|
8
|
+
if (code >= 33 && code <= 126) {
|
|
9
|
+
result += String.fromCharCode(str.charCodeAt(i) + 65248);
|
|
10
|
+
}
|
|
11
|
+
else if (code == 32) {
|
|
12
|
+
result += String.fromCharCode(str.charCodeAt(i) + 12288 - 32);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
result += str.charAt(i);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
package/lib/filterIdCard.d.ts
CHANGED
package/lib/filterIdCard.js
CHANGED
package/lib/formatDateStr.d.ts
CHANGED
package/lib/formatDateStr.js
CHANGED
package/lib/getRandom.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandom = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 生成一个随机字符串
|
|
6
|
+
* @param length 生成随机字符串的长度
|
|
7
|
+
* @param alphabet 字母表
|
|
8
|
+
*/
|
|
9
|
+
function getRandom(length, alphabet = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM') {
|
|
10
|
+
return new Array(length)
|
|
11
|
+
.fill('')
|
|
12
|
+
.map(() => alphabet[Math.floor(Math.random() * alphabet.length)])
|
|
13
|
+
.join('');
|
|
14
|
+
}
|
|
15
|
+
exports.getRandom = getRandom;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomNumber = void 0;
|
|
4
|
+
const getRandom_1 = require("./getRandom");
|
|
5
|
+
/**
|
|
6
|
+
* 生成一个随机数字
|
|
7
|
+
* @param length 生成一个随机数字的长度
|
|
8
|
+
*/
|
|
9
|
+
function getRandomNumber(length) {
|
|
10
|
+
return (0, getRandom_1.getRandom)(length, '1234567890');
|
|
11
|
+
}
|
|
12
|
+
exports.getRandomNumber = getRandomNumber;
|
package/lib/index.d.ts
CHANGED
|
@@ -25,21 +25,26 @@ export * from './formatPathParams';
|
|
|
25
25
|
export * from './getBlobByUrl';
|
|
26
26
|
export * from './getDayMillisecond';
|
|
27
27
|
export * from './getImageInfo';
|
|
28
|
+
export * from './getRandom';
|
|
28
29
|
export * from './getRandomColor';
|
|
30
|
+
export * from './getRandomNumber';
|
|
29
31
|
export * from './getVideoInfo';
|
|
30
32
|
export * from './inBrowser';
|
|
31
33
|
export * from './insertLink';
|
|
32
34
|
export * from './insertScript';
|
|
33
35
|
export * from './insertStyle';
|
|
36
|
+
export * from './isAmount';
|
|
34
37
|
export * from './isAndroid';
|
|
35
38
|
export * from './isArray';
|
|
36
39
|
export * from './isBoolean';
|
|
40
|
+
export * from './isChinese';
|
|
37
41
|
export * from './isDate';
|
|
38
42
|
export * from './isEmail';
|
|
39
43
|
export * from './isEmpty';
|
|
40
44
|
export * from './isEmptyObject';
|
|
41
45
|
export * from './isError';
|
|
42
46
|
export * from './isFunction';
|
|
47
|
+
export * from './isIE';
|
|
43
48
|
export * from './isIOS';
|
|
44
49
|
export * from './isIdCard';
|
|
45
50
|
export * from './isJSONString';
|
|
@@ -55,7 +60,8 @@ export * from './isRegExp';
|
|
|
55
60
|
export * from './isString';
|
|
56
61
|
export * from './isURL';
|
|
57
62
|
export * from './isUndefined';
|
|
58
|
-
export * from './
|
|
63
|
+
export * from './isWeChat';
|
|
64
|
+
export * from './isWeChatMiniProgram';
|
|
59
65
|
export * from './isWindow';
|
|
60
66
|
export * from './kebabCase';
|
|
61
67
|
export * from './mousewheel';
|
|
@@ -73,10 +79,13 @@ export * from './replaceCrlf';
|
|
|
73
79
|
export * from './reserve';
|
|
74
80
|
export * from './rgbToHex';
|
|
75
81
|
export * from './round';
|
|
82
|
+
export * from './scrollToTop';
|
|
76
83
|
export * from './sleep';
|
|
77
84
|
export * from './splitArray';
|
|
78
85
|
export * from './storage';
|
|
79
86
|
export * from './stringTrim';
|
|
80
87
|
export * from './stringifyQuery';
|
|
81
88
|
export * from './throttle';
|
|
89
|
+
export * from './toCDB';
|
|
90
|
+
export * from './toDBC';
|
|
82
91
|
export * from './typeOf';
|
package/lib/index.js
CHANGED
|
@@ -42,21 +42,26 @@ __exportStar(require("./formatPathParams"), exports);
|
|
|
42
42
|
__exportStar(require("./getBlobByUrl"), exports);
|
|
43
43
|
__exportStar(require("./getDayMillisecond"), exports);
|
|
44
44
|
__exportStar(require("./getImageInfo"), exports);
|
|
45
|
+
__exportStar(require("./getRandom"), exports);
|
|
45
46
|
__exportStar(require("./getRandomColor"), exports);
|
|
47
|
+
__exportStar(require("./getRandomNumber"), exports);
|
|
46
48
|
__exportStar(require("./getVideoInfo"), exports);
|
|
47
49
|
__exportStar(require("./inBrowser"), exports);
|
|
48
50
|
__exportStar(require("./insertLink"), exports);
|
|
49
51
|
__exportStar(require("./insertScript"), exports);
|
|
50
52
|
__exportStar(require("./insertStyle"), exports);
|
|
53
|
+
__exportStar(require("./isAmount"), exports);
|
|
51
54
|
__exportStar(require("./isAndroid"), exports);
|
|
52
55
|
__exportStar(require("./isArray"), exports);
|
|
53
56
|
__exportStar(require("./isBoolean"), exports);
|
|
57
|
+
__exportStar(require("./isChinese"), exports);
|
|
54
58
|
__exportStar(require("./isDate"), exports);
|
|
55
59
|
__exportStar(require("./isEmail"), exports);
|
|
56
60
|
__exportStar(require("./isEmpty"), exports);
|
|
57
61
|
__exportStar(require("./isEmptyObject"), exports);
|
|
58
62
|
__exportStar(require("./isError"), exports);
|
|
59
63
|
__exportStar(require("./isFunction"), exports);
|
|
64
|
+
__exportStar(require("./isIE"), exports);
|
|
60
65
|
__exportStar(require("./isIOS"), exports);
|
|
61
66
|
__exportStar(require("./isIdCard"), exports);
|
|
62
67
|
__exportStar(require("./isJSONString"), exports);
|
|
@@ -72,7 +77,8 @@ __exportStar(require("./isRegExp"), exports);
|
|
|
72
77
|
__exportStar(require("./isString"), exports);
|
|
73
78
|
__exportStar(require("./isURL"), exports);
|
|
74
79
|
__exportStar(require("./isUndefined"), exports);
|
|
75
|
-
__exportStar(require("./
|
|
80
|
+
__exportStar(require("./isWeChat"), exports);
|
|
81
|
+
__exportStar(require("./isWeChatMiniProgram"), exports);
|
|
76
82
|
__exportStar(require("./isWindow"), exports);
|
|
77
83
|
__exportStar(require("./kebabCase"), exports);
|
|
78
84
|
__exportStar(require("./mousewheel"), exports);
|
|
@@ -90,10 +96,13 @@ __exportStar(require("./replaceCrlf"), exports);
|
|
|
90
96
|
__exportStar(require("./reserve"), exports);
|
|
91
97
|
__exportStar(require("./rgbToHex"), exports);
|
|
92
98
|
__exportStar(require("./round"), exports);
|
|
99
|
+
__exportStar(require("./scrollToTop"), exports);
|
|
93
100
|
__exportStar(require("./sleep"), exports);
|
|
94
101
|
__exportStar(require("./splitArray"), exports);
|
|
95
102
|
__exportStar(require("./storage"), exports);
|
|
96
103
|
__exportStar(require("./stringTrim"), exports);
|
|
97
104
|
__exportStar(require("./stringifyQuery"), exports);
|
|
98
105
|
__exportStar(require("./throttle"), exports);
|
|
106
|
+
__exportStar(require("./toCDB"), exports);
|
|
107
|
+
__exportStar(require("./toDBC"), exports);
|
|
99
108
|
__exportStar(require("./typeOf"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是合法金额
|
|
3
|
+
* 只能是数字,小数点后只能保留两位或一位
|
|
4
|
+
* isAmount(0) => true
|
|
5
|
+
* isAmount('01') => false
|
|
6
|
+
* isAmount('1.') => true
|
|
7
|
+
* isAmount('1.1') => true
|
|
8
|
+
* isAmount('1.12') => true
|
|
9
|
+
* isAmount('1.123') => false
|
|
10
|
+
*/
|
|
11
|
+
export declare function isAmount(val: string): boolean;
|
package/lib/isAmount.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAmount = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 判断是否是合法金额
|
|
6
|
+
* 只能是数字,小数点后只能保留两位或一位
|
|
7
|
+
* isAmount(0) => true
|
|
8
|
+
* isAmount('01') => false
|
|
9
|
+
* isAmount('1.') => true
|
|
10
|
+
* isAmount('1.1') => true
|
|
11
|
+
* isAmount('1.12') => true
|
|
12
|
+
* isAmount('1.123') => false
|
|
13
|
+
*/
|
|
14
|
+
function isAmount(val) {
|
|
15
|
+
return /^([1-9]\d*|0)([.]?|(\.\d{1,2})?)$/.test(val);
|
|
16
|
+
}
|
|
17
|
+
exports.isAmount = isAmount;
|
package/lib/isChinese.js
ADDED
package/lib/isEmptyObject.d.ts
CHANGED