@daysnap/utils 0.0.57 → 0.0.59
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/README.md +1 -0
- package/docs/README.md +2 -0
- package/docs/modules.md +453 -90
- package/es/cached.d.ts +5 -0
- package/es/cached.js +12 -0
- package/es/exitFullscreen.d.ts +6 -0
- package/es/exitFullscreen.js +27 -0
- package/es/getRandom.js +2 -4
- package/es/index.d.ts +7 -0
- package/es/index.js +7 -0
- 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/isNativeFunction.d.ts +5 -0
- package/es/isNativeFunction.js +8 -0
- package/es/listGenerator.d.ts +5 -0
- package/es/listGenerator.js +7 -0
- package/es/requestFullScreen.d.ts +6 -0
- package/es/requestFullScreen.js +27 -0
- package/lib/cached.d.ts +5 -0
- package/lib/cached.js +16 -0
- package/lib/exitFullscreen.d.ts +6 -0
- package/lib/exitFullscreen.js +31 -0
- package/lib/getRandom.js +2 -4
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -0
- 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/isNativeFunction.d.ts +5 -0
- package/lib/isNativeFunction.js +12 -0
- package/lib/listGenerator.d.ts +5 -0
- package/lib/listGenerator.js +11 -0
- package/lib/requestFullScreen.d.ts +6 -0
- package/lib/requestFullScreen.js +31 -0
- package/package.json +1 -1
package/es/cached.d.ts
ADDED
package/es/cached.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存、记忆函数,缓存函数的运算结果
|
|
3
|
+
* 需注意缓存的函数得是纯函数
|
|
4
|
+
*/
|
|
5
|
+
export function cached(fn) {
|
|
6
|
+
const cache = Object.create(null);
|
|
7
|
+
return function cachedFn(...args) {
|
|
8
|
+
const key = JSON.stringify(args);
|
|
9
|
+
const hit = cache[key];
|
|
10
|
+
return hit || (cache[key] = fn(...args));
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 退出全屏
|
|
12
|
+
* 成功则 resolve , 如果不支持退出全屏或退出失败则 rejected
|
|
13
|
+
* [MDN Reference](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/exitFullscreen)
|
|
14
|
+
*/
|
|
15
|
+
export function exitFullscreen() {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const doc = window.document;
|
|
18
|
+
const exit = doc.exitFullscreen ||
|
|
19
|
+
doc.msExitFullscreen ||
|
|
20
|
+
doc.mozCancelFullScreen ||
|
|
21
|
+
doc.webkitExitFullscreen;
|
|
22
|
+
if (exit) {
|
|
23
|
+
return yield exit();
|
|
24
|
+
}
|
|
25
|
+
return Promise.reject();
|
|
26
|
+
});
|
|
27
|
+
}
|
package/es/getRandom.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { listGenerator } from './listGenerator';
|
|
1
2
|
/**
|
|
2
3
|
* 生成一个随机字符串
|
|
3
4
|
* @param length 生成随机字符串的长度
|
|
4
5
|
* @param alphabet 字母表
|
|
5
6
|
*/
|
|
6
7
|
export function getRandom(length, alphabet = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM') {
|
|
7
|
-
return
|
|
8
|
-
.fill('')
|
|
9
|
-
.map(() => alphabet[Math.floor(Math.random() * alphabet.length)])
|
|
10
|
-
.join('');
|
|
8
|
+
return listGenerator(length, () => alphabet[Math.floor(Math.random() * alphabet.length)]).join('');
|
|
11
9
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './base64ToBlob';
|
|
2
2
|
export * from './blobToBase64';
|
|
3
|
+
export * from './cached';
|
|
3
4
|
export * from './camelCase';
|
|
4
5
|
export * from './canvasToBlob';
|
|
5
6
|
export * from './capitalize';
|
|
@@ -11,6 +12,7 @@ export * from './createHexColorByHash';
|
|
|
11
12
|
export * from './debounce';
|
|
12
13
|
export * from './downloadFile';
|
|
13
14
|
export * from './each';
|
|
15
|
+
export * from './exitFullscreen';
|
|
14
16
|
export * from './filterBankCardNo';
|
|
15
17
|
export * from './filterCRLF';
|
|
16
18
|
export * from './filterEmoji';
|
|
@@ -33,9 +35,11 @@ export * from './inBrowser';
|
|
|
33
35
|
export * from './insertLink';
|
|
34
36
|
export * from './insertScript';
|
|
35
37
|
export * from './insertStyle';
|
|
38
|
+
export * from './isAmount';
|
|
36
39
|
export * from './isAndroid';
|
|
37
40
|
export * from './isArray';
|
|
38
41
|
export * from './isBoolean';
|
|
42
|
+
export * from './isChinese';
|
|
39
43
|
export * from './isDate';
|
|
40
44
|
export * from './isEmail';
|
|
41
45
|
export * from './isEmpty';
|
|
@@ -49,6 +53,7 @@ export * from './isJSONString';
|
|
|
49
53
|
export * from './isLan';
|
|
50
54
|
export * from './isLicenseCode';
|
|
51
55
|
export * from './isMobile';
|
|
56
|
+
export * from './isNativeFunction';
|
|
52
57
|
export * from './isNull';
|
|
53
58
|
export * from './isNumber';
|
|
54
59
|
export * from './isObject';
|
|
@@ -62,6 +67,7 @@ export * from './isWeChat';
|
|
|
62
67
|
export * from './isWeChatMiniProgram';
|
|
63
68
|
export * from './isWindow';
|
|
64
69
|
export * from './kebabCase';
|
|
70
|
+
export * from './listGenerator';
|
|
65
71
|
export * from './mousewheel';
|
|
66
72
|
export * from './normalizePath';
|
|
67
73
|
export * from './omit';
|
|
@@ -74,6 +80,7 @@ export * from './parseQuery';
|
|
|
74
80
|
export * from './pascalCase';
|
|
75
81
|
export * from './pick';
|
|
76
82
|
export * from './replaceCrlf';
|
|
83
|
+
export * from './requestFullScreen';
|
|
77
84
|
export * from './reserve';
|
|
78
85
|
export * from './rgbToHex';
|
|
79
86
|
export * from './round';
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* 本文件自动生成 './scripts/entry.js' */
|
|
2
2
|
export * from './base64ToBlob';
|
|
3
3
|
export * from './blobToBase64';
|
|
4
|
+
export * from './cached';
|
|
4
5
|
export * from './camelCase';
|
|
5
6
|
export * from './canvasToBlob';
|
|
6
7
|
export * from './capitalize';
|
|
@@ -12,6 +13,7 @@ export * from './createHexColorByHash';
|
|
|
12
13
|
export * from './debounce';
|
|
13
14
|
export * from './downloadFile';
|
|
14
15
|
export * from './each';
|
|
16
|
+
export * from './exitFullscreen';
|
|
15
17
|
export * from './filterBankCardNo';
|
|
16
18
|
export * from './filterCRLF';
|
|
17
19
|
export * from './filterEmoji';
|
|
@@ -34,9 +36,11 @@ export * from './inBrowser';
|
|
|
34
36
|
export * from './insertLink';
|
|
35
37
|
export * from './insertScript';
|
|
36
38
|
export * from './insertStyle';
|
|
39
|
+
export * from './isAmount';
|
|
37
40
|
export * from './isAndroid';
|
|
38
41
|
export * from './isArray';
|
|
39
42
|
export * from './isBoolean';
|
|
43
|
+
export * from './isChinese';
|
|
40
44
|
export * from './isDate';
|
|
41
45
|
export * from './isEmail';
|
|
42
46
|
export * from './isEmpty';
|
|
@@ -50,6 +54,7 @@ export * from './isJSONString';
|
|
|
50
54
|
export * from './isLan';
|
|
51
55
|
export * from './isLicenseCode';
|
|
52
56
|
export * from './isMobile';
|
|
57
|
+
export * from './isNativeFunction';
|
|
53
58
|
export * from './isNull';
|
|
54
59
|
export * from './isNumber';
|
|
55
60
|
export * from './isObject';
|
|
@@ -63,6 +68,7 @@ export * from './isWeChat';
|
|
|
63
68
|
export * from './isWeChatMiniProgram';
|
|
64
69
|
export * from './isWindow';
|
|
65
70
|
export * from './kebabCase';
|
|
71
|
+
export * from './listGenerator';
|
|
66
72
|
export * from './mousewheel';
|
|
67
73
|
export * from './normalizePath';
|
|
68
74
|
export * from './omit';
|
|
@@ -75,6 +81,7 @@ export * from './parseQuery';
|
|
|
75
81
|
export * from './pascalCase';
|
|
76
82
|
export * from './pick';
|
|
77
83
|
export * from './replaceCrlf';
|
|
84
|
+
export * from './requestFullScreen';
|
|
78
85
|
export * from './reserve';
|
|
79
86
|
export * from './rgbToHex';
|
|
80
87
|
export * from './round';
|
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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 开启全屏
|
|
12
|
+
* 成功则 resolve , 如果不支持全屏或开启失败则 rejected
|
|
13
|
+
* [MDN Reference] https://developer.mozilla.org/zh-CN/docs/Web/API/Element/requestFullscreen
|
|
14
|
+
*/
|
|
15
|
+
export function requestFullScreen(ele = window.document.documentElement) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const element = ele;
|
|
18
|
+
const fullScreen = element.requestFullscreen ||
|
|
19
|
+
element.mozRequestFullScreen ||
|
|
20
|
+
element.msRequestFullscreen ||
|
|
21
|
+
element.webkitRequestFullscreen;
|
|
22
|
+
if (fullScreen) {
|
|
23
|
+
return yield fullScreen.call(element);
|
|
24
|
+
}
|
|
25
|
+
return Promise.reject();
|
|
26
|
+
});
|
|
27
|
+
}
|
package/lib/cached.d.ts
ADDED
package/lib/cached.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cached = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 缓存、记忆函数,缓存函数的运算结果
|
|
6
|
+
* 需注意缓存的函数得是纯函数
|
|
7
|
+
*/
|
|
8
|
+
function cached(fn) {
|
|
9
|
+
const cache = Object.create(null);
|
|
10
|
+
return function cachedFn(...args) {
|
|
11
|
+
const key = JSON.stringify(args);
|
|
12
|
+
const hit = cache[key];
|
|
13
|
+
return hit || (cache[key] = fn(...args));
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.cached = cached;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.exitFullscreen = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 退出全屏
|
|
15
|
+
* 成功则 resolve , 如果不支持退出全屏或退出失败则 rejected
|
|
16
|
+
* [MDN Reference](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/exitFullscreen)
|
|
17
|
+
*/
|
|
18
|
+
function exitFullscreen() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const doc = window.document;
|
|
21
|
+
const exit = doc.exitFullscreen ||
|
|
22
|
+
doc.msExitFullscreen ||
|
|
23
|
+
doc.mozCancelFullScreen ||
|
|
24
|
+
doc.webkitExitFullscreen;
|
|
25
|
+
if (exit) {
|
|
26
|
+
return yield exit();
|
|
27
|
+
}
|
|
28
|
+
return Promise.reject();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.exitFullscreen = exitFullscreen;
|
package/lib/getRandom.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRandom = void 0;
|
|
4
|
+
const listGenerator_1 = require("./listGenerator");
|
|
4
5
|
/**
|
|
5
6
|
* 生成一个随机字符串
|
|
6
7
|
* @param length 生成随机字符串的长度
|
|
7
8
|
* @param alphabet 字母表
|
|
8
9
|
*/
|
|
9
10
|
function getRandom(length, alphabet = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM') {
|
|
10
|
-
return
|
|
11
|
-
.fill('')
|
|
12
|
-
.map(() => alphabet[Math.floor(Math.random() * alphabet.length)])
|
|
13
|
-
.join('');
|
|
11
|
+
return (0, listGenerator_1.listGenerator)(length, () => alphabet[Math.floor(Math.random() * alphabet.length)]).join('');
|
|
14
12
|
}
|
|
15
13
|
exports.getRandom = getRandom;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './base64ToBlob';
|
|
2
2
|
export * from './blobToBase64';
|
|
3
|
+
export * from './cached';
|
|
3
4
|
export * from './camelCase';
|
|
4
5
|
export * from './canvasToBlob';
|
|
5
6
|
export * from './capitalize';
|
|
@@ -11,6 +12,7 @@ export * from './createHexColorByHash';
|
|
|
11
12
|
export * from './debounce';
|
|
12
13
|
export * from './downloadFile';
|
|
13
14
|
export * from './each';
|
|
15
|
+
export * from './exitFullscreen';
|
|
14
16
|
export * from './filterBankCardNo';
|
|
15
17
|
export * from './filterCRLF';
|
|
16
18
|
export * from './filterEmoji';
|
|
@@ -33,9 +35,11 @@ export * from './inBrowser';
|
|
|
33
35
|
export * from './insertLink';
|
|
34
36
|
export * from './insertScript';
|
|
35
37
|
export * from './insertStyle';
|
|
38
|
+
export * from './isAmount';
|
|
36
39
|
export * from './isAndroid';
|
|
37
40
|
export * from './isArray';
|
|
38
41
|
export * from './isBoolean';
|
|
42
|
+
export * from './isChinese';
|
|
39
43
|
export * from './isDate';
|
|
40
44
|
export * from './isEmail';
|
|
41
45
|
export * from './isEmpty';
|
|
@@ -49,6 +53,7 @@ export * from './isJSONString';
|
|
|
49
53
|
export * from './isLan';
|
|
50
54
|
export * from './isLicenseCode';
|
|
51
55
|
export * from './isMobile';
|
|
56
|
+
export * from './isNativeFunction';
|
|
52
57
|
export * from './isNull';
|
|
53
58
|
export * from './isNumber';
|
|
54
59
|
export * from './isObject';
|
|
@@ -62,6 +67,7 @@ export * from './isWeChat';
|
|
|
62
67
|
export * from './isWeChatMiniProgram';
|
|
63
68
|
export * from './isWindow';
|
|
64
69
|
export * from './kebabCase';
|
|
70
|
+
export * from './listGenerator';
|
|
65
71
|
export * from './mousewheel';
|
|
66
72
|
export * from './normalizePath';
|
|
67
73
|
export * from './omit';
|
|
@@ -74,6 +80,7 @@ export * from './parseQuery';
|
|
|
74
80
|
export * from './pascalCase';
|
|
75
81
|
export * from './pick';
|
|
76
82
|
export * from './replaceCrlf';
|
|
83
|
+
export * from './requestFullScreen';
|
|
77
84
|
export * from './reserve';
|
|
78
85
|
export * from './rgbToHex';
|
|
79
86
|
export * from './round';
|
package/lib/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
__exportStar(require("./base64ToBlob"), exports);
|
|
19
19
|
__exportStar(require("./blobToBase64"), exports);
|
|
20
|
+
__exportStar(require("./cached"), exports);
|
|
20
21
|
__exportStar(require("./camelCase"), exports);
|
|
21
22
|
__exportStar(require("./canvasToBlob"), exports);
|
|
22
23
|
__exportStar(require("./capitalize"), exports);
|
|
@@ -28,6 +29,7 @@ __exportStar(require("./createHexColorByHash"), exports);
|
|
|
28
29
|
__exportStar(require("./debounce"), exports);
|
|
29
30
|
__exportStar(require("./downloadFile"), exports);
|
|
30
31
|
__exportStar(require("./each"), exports);
|
|
32
|
+
__exportStar(require("./exitFullscreen"), exports);
|
|
31
33
|
__exportStar(require("./filterBankCardNo"), exports);
|
|
32
34
|
__exportStar(require("./filterCRLF"), exports);
|
|
33
35
|
__exportStar(require("./filterEmoji"), exports);
|
|
@@ -50,9 +52,11 @@ __exportStar(require("./inBrowser"), exports);
|
|
|
50
52
|
__exportStar(require("./insertLink"), exports);
|
|
51
53
|
__exportStar(require("./insertScript"), exports);
|
|
52
54
|
__exportStar(require("./insertStyle"), exports);
|
|
55
|
+
__exportStar(require("./isAmount"), exports);
|
|
53
56
|
__exportStar(require("./isAndroid"), exports);
|
|
54
57
|
__exportStar(require("./isArray"), exports);
|
|
55
58
|
__exportStar(require("./isBoolean"), exports);
|
|
59
|
+
__exportStar(require("./isChinese"), exports);
|
|
56
60
|
__exportStar(require("./isDate"), exports);
|
|
57
61
|
__exportStar(require("./isEmail"), exports);
|
|
58
62
|
__exportStar(require("./isEmpty"), exports);
|
|
@@ -66,6 +70,7 @@ __exportStar(require("./isJSONString"), exports);
|
|
|
66
70
|
__exportStar(require("./isLan"), exports);
|
|
67
71
|
__exportStar(require("./isLicenseCode"), exports);
|
|
68
72
|
__exportStar(require("./isMobile"), exports);
|
|
73
|
+
__exportStar(require("./isNativeFunction"), exports);
|
|
69
74
|
__exportStar(require("./isNull"), exports);
|
|
70
75
|
__exportStar(require("./isNumber"), exports);
|
|
71
76
|
__exportStar(require("./isObject"), exports);
|
|
@@ -79,6 +84,7 @@ __exportStar(require("./isWeChat"), exports);
|
|
|
79
84
|
__exportStar(require("./isWeChatMiniProgram"), exports);
|
|
80
85
|
__exportStar(require("./isWindow"), exports);
|
|
81
86
|
__exportStar(require("./kebabCase"), exports);
|
|
87
|
+
__exportStar(require("./listGenerator"), exports);
|
|
82
88
|
__exportStar(require("./mousewheel"), exports);
|
|
83
89
|
__exportStar(require("./normalizePath"), exports);
|
|
84
90
|
__exportStar(require("./omit"), exports);
|
|
@@ -91,6 +97,7 @@ __exportStar(require("./parseQuery"), exports);
|
|
|
91
97
|
__exportStar(require("./pascalCase"), exports);
|
|
92
98
|
__exportStar(require("./pick"), exports);
|
|
93
99
|
__exportStar(require("./replaceCrlf"), exports);
|
|
100
|
+
__exportStar(require("./requestFullScreen"), exports);
|
|
94
101
|
__exportStar(require("./reserve"), exports);
|
|
95
102
|
__exportStar(require("./rgbToHex"), exports);
|
|
96
103
|
__exportStar(require("./round"), 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNativeFunction = void 0;
|
|
4
|
+
const isFunction_1 = require("./isFunction");
|
|
5
|
+
/**
|
|
6
|
+
* 判断是不是内置函数
|
|
7
|
+
* 内置函数toString后的主体代码块为 [native code]
|
|
8
|
+
*/
|
|
9
|
+
function isNativeFunction(val) {
|
|
10
|
+
return (0, isFunction_1.isFunction)(val) && /native code/.test(val.toString());
|
|
11
|
+
}
|
|
12
|
+
exports.isNativeFunction = isNativeFunction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listGenerator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* list 生成器,快速生成数据
|
|
6
|
+
* @param length 个数
|
|
7
|
+
*/
|
|
8
|
+
function listGenerator(length, fn) {
|
|
9
|
+
return new Array(length).fill('').map((_, index) => fn(index));
|
|
10
|
+
}
|
|
11
|
+
exports.listGenerator = listGenerator;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.requestFullScreen = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* 开启全屏
|
|
15
|
+
* 成功则 resolve , 如果不支持全屏或开启失败则 rejected
|
|
16
|
+
* [MDN Reference] https://developer.mozilla.org/zh-CN/docs/Web/API/Element/requestFullscreen
|
|
17
|
+
*/
|
|
18
|
+
function requestFullScreen(ele = window.document.documentElement) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const element = ele;
|
|
21
|
+
const fullScreen = element.requestFullscreen ||
|
|
22
|
+
element.mozRequestFullScreen ||
|
|
23
|
+
element.msRequestFullscreen ||
|
|
24
|
+
element.webkitRequestFullscreen;
|
|
25
|
+
if (fullScreen) {
|
|
26
|
+
return yield fullScreen.call(element);
|
|
27
|
+
}
|
|
28
|
+
return Promise.reject();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.requestFullScreen = requestFullScreen;
|