ddan-js 2.9.3 → 2.9.5
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/bin/ddan-js.browser.js +1 -1
- package/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/types/browser.d.ts +3 -3
- package/bin/types/index.d.ts +4 -3
- package/bin/types/modules/fetch.d.ts +1 -1
- package/bin/types/modules/node/index.d.ts +2 -0
- package/package.json +18 -13
- package/bin/lib/browser.js +0 -111
- package/bin/lib/class/event.js +0 -104
- package/bin/lib/class/getset.js +0 -12
- package/bin/lib/class/icon.js +0 -94
- package/bin/lib/class/joker.js +0 -121
- package/bin/lib/class/kvalue.js +0 -29
- package/bin/lib/class/mapping.js +0 -82
- package/bin/lib/class/persist.js +0 -65
- package/bin/lib/class/pipeTask.js +0 -42
- package/bin/lib/class/pipeparallel.js +0 -24
- package/bin/lib/class/store.js +0 -87
- package/bin/lib/class/tracker.js +0 -125
- package/bin/lib/class/watermark.js +0 -63
- package/bin/lib/common/_Symbol.js +0 -5
- package/bin/lib/common/_freeGlobal.js +0 -5
- package/bin/lib/common/_object.js +0 -40
- package/bin/lib/common/_root.js +0 -10
- package/bin/lib/common/internal/asciiToArray.js +0 -13
- package/bin/lib/common/internal/castSlice.js +0 -18
- package/bin/lib/common/internal/createCaseFirst.js +0 -30
- package/bin/lib/common/internal/hasUnicode.js +0 -26
- package/bin/lib/common/internal/nodeTypes.js +0 -26
- package/bin/lib/common/internal/slice.js +0 -46
- package/bin/lib/common/internal/stringToArray.js +0 -18
- package/bin/lib/common/internal/unicodeToArray.js +0 -40
- package/bin/lib/common/internal/unicodeWords.js +0 -67
- package/bin/lib/index.js +0 -114
- package/bin/lib/modules/browser/ecdh.js +0 -124
- package/bin/lib/modules/browser/index.js +0 -4
- package/bin/lib/modules/cdn.js +0 -62
- package/bin/lib/modules/convert/base.js +0 -125
- package/bin/lib/modules/convert/base64.js +0 -114
- package/bin/lib/modules/convert/index.js +0 -99
- package/bin/lib/modules/convert/md5.js +0 -222
- package/bin/lib/modules/convert/pkcs.js +0 -16
- package/bin/lib/modules/convert/utf8.js +0 -106
- package/bin/lib/modules/crypto/base64.js +0 -14
- package/bin/lib/modules/crypto/const.js +0 -7
- package/bin/lib/modules/crypto/index.js +0 -30
- package/bin/lib/modules/crypto/rsa.js +0 -143
- package/bin/lib/modules/crypto/tea.js +0 -79
- package/bin/lib/modules/crypto/uuid.js +0 -34
- package/bin/lib/modules/css.js +0 -137
- package/bin/lib/modules/decorator.js +0 -14
- package/bin/lib/modules/fetch.js +0 -82
- package/bin/lib/modules/gbk.js +0 -46
- package/bin/lib/modules/hook/base.js +0 -60
- package/bin/lib/modules/hook/hooker.js +0 -39
- package/bin/lib/modules/hook/index.js +0 -49
- package/bin/lib/modules/hook/log.js +0 -54
- package/bin/lib/modules/hook/modules/bezier.js +0 -121
- package/bin/lib/modules/hook/modules/debounce.js +0 -127
- package/bin/lib/modules/hook/modules/mutex.js +0 -22
- package/bin/lib/modules/hook/modules/pipeline.js +0 -59
- package/bin/lib/modules/hook/modules/polling.js +0 -20
- package/bin/lib/modules/hook/modules/safeTask.js +0 -25
- package/bin/lib/modules/hook/modules/throttle.js +0 -30
- package/bin/lib/modules/html.js +0 -293
- package/bin/lib/modules/http/index.js +0 -171
- package/bin/lib/modules/http/interceptor.js +0 -22
- package/bin/lib/modules/list/base.js +0 -37
- package/bin/lib/modules/list/index.js +0 -90
- package/bin/lib/modules/logger.js +0 -55
- package/bin/lib/modules/math/index.js +0 -118
- package/bin/lib/modules/mini/diff.js +0 -97
- package/bin/lib/modules/mini/http/index.js +0 -155
- package/bin/lib/modules/mini/index.js +0 -71
- package/bin/lib/modules/node/aliyun.js +0 -156
- package/bin/lib/modules/node/brotli.js +0 -46
- package/bin/lib/modules/node/child.js +0 -18
- package/bin/lib/modules/node/ecdh-web.js +0 -11
- package/bin/lib/modules/node/ecdh.js +0 -115
- package/bin/lib/modules/node/file.js +0 -25
- package/bin/lib/modules/node/index.js +0 -11
- package/bin/lib/modules/node/proxy.js +0 -147
- package/bin/lib/modules/node/rsa-web.js +0 -19
- package/bin/lib/modules/node/socks5.js +0 -424
- package/bin/lib/modules/obj/index.js +0 -184
- package/bin/lib/modules/qs/base.js +0 -5
- package/bin/lib/modules/qs/decode.js +0 -45
- package/bin/lib/modules/qs/encode.js +0 -53
- package/bin/lib/modules/qs/index.js +0 -114
- package/bin/lib/modules/regex.js +0 -16
- package/bin/lib/modules/rsa.js +0 -18
- package/bin/lib/modules/rule/async-validator/index.js +0 -306
- package/bin/lib/modules/rule/async-validator/interface.js +0 -2
- package/bin/lib/modules/rule/async-validator/messages.js +0 -59
- package/bin/lib/modules/rule/async-validator/rule/enum.js +0 -13
- package/bin/lib/modules/rule/async-validator/rule/index.js +0 -16
- package/bin/lib/modules/rule/async-validator/rule/pattern.js +0 -27
- package/bin/lib/modules/rule/async-validator/rule/range.js +0 -54
- package/bin/lib/modules/rule/async-validator/rule/required.js +0 -12
- package/bin/lib/modules/rule/async-validator/rule/type.js +0 -98
- package/bin/lib/modules/rule/async-validator/rule/url.js +0 -55
- package/bin/lib/modules/rule/async-validator/rule/whitespace.js +0 -20
- package/bin/lib/modules/rule/async-validator/util.js +0 -255
- package/bin/lib/modules/rule/async-validator/validator/any.js +0 -16
- package/bin/lib/modules/rule/async-validator/validator/array.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/boolean.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/date.js +0 -31
- package/bin/lib/modules/rule/async-validator/validator/enum.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/float.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/index.js +0 -36
- package/bin/lib/modules/rule/async-validator/validator/integer.js +0 -20
- package/bin/lib/modules/rule/async-validator/validator/method.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/number.js +0 -23
- package/bin/lib/modules/rule/async-validator/validator/object.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/pattern.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/regexp.js +0 -19
- package/bin/lib/modules/rule/async-validator/validator/required.js +0 -10
- package/bin/lib/modules/rule/async-validator/validator/string.js +0 -24
- package/bin/lib/modules/rule/async-validator/validator/type.js +0 -20
- package/bin/lib/modules/rule/index.js +0 -67
- package/bin/lib/modules/string/index.js +0 -121
- package/bin/lib/modules/string/words.js +0 -33
- package/bin/lib/modules/time/const.js +0 -11
- package/bin/lib/modules/time/dtime.js +0 -132
- package/bin/lib/modules/time/frame.js +0 -49
- package/bin/lib/modules/time/index.js +0 -84
- package/bin/lib/typings/index.js +0 -2
- package/bin/lib/util/function.js +0 -33
- package/bin/lib/util/includes.js +0 -96
- package/bin/lib/util/index.js +0 -26
- package/bin/lib/util/is.js +0 -148
- package/bin/lib/util/to.js +0 -47
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const object = (rule, value, callback, source, options) => {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
|
|
8
|
-
if (validate) {
|
|
9
|
-
if ((0, util_1.isEmptyValue)(value) && !rule.required) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
rule_1.default.required(rule, value, source, errors, options);
|
|
13
|
-
if (value !== undefined) {
|
|
14
|
-
rule_1.default.type(rule, value, source, errors, options);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
callback(errors);
|
|
18
|
-
};
|
|
19
|
-
exports.default = object;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const pattern = (rule, value, callback, source, options) => {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
|
|
8
|
-
if (validate) {
|
|
9
|
-
if ((0, util_1.isEmptyValue)(value, 'string') && !rule.required) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
rule_1.default.required(rule, value, source, errors, options);
|
|
13
|
-
if (!(0, util_1.isEmptyValue)(value, 'string')) {
|
|
14
|
-
rule_1.default.pattern(rule, value, source, errors, options);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
callback(errors);
|
|
18
|
-
};
|
|
19
|
-
exports.default = pattern;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const regexp = (rule, value, callback, source, options) => {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
|
|
8
|
-
if (validate) {
|
|
9
|
-
if ((0, util_1.isEmptyValue)(value) && !rule.required) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
rule_1.default.required(rule, value, source, errors, options);
|
|
13
|
-
if (!(0, util_1.isEmptyValue)(value)) {
|
|
14
|
-
rule_1.default.type(rule, value, source, errors, options);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
callback(errors);
|
|
18
|
-
};
|
|
19
|
-
exports.default = regexp;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const required = (rule, value, callback, source, options) => {
|
|
5
|
-
const errors = [];
|
|
6
|
-
const type = Array.isArray(value) ? 'array' : typeof value;
|
|
7
|
-
rule_1.default.required(rule, value, source, errors, options, type);
|
|
8
|
-
callback(errors);
|
|
9
|
-
};
|
|
10
|
-
exports.default = required;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const string = (rule, value, callback, source, options) => {
|
|
6
|
-
const errors = [];
|
|
7
|
-
const validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field || ""));
|
|
8
|
-
if (validate) {
|
|
9
|
-
if ((0, util_1.isEmptyValue)(value, 'string') && !rule.required) {
|
|
10
|
-
return callback();
|
|
11
|
-
}
|
|
12
|
-
rule_1.default.required(rule, value, source, errors, options, 'string');
|
|
13
|
-
if (!(0, util_1.isEmptyValue)(value, 'string')) {
|
|
14
|
-
rule_1.default.type(rule, value, source, errors, options);
|
|
15
|
-
rule_1.default.range(rule, value, source, errors, options);
|
|
16
|
-
rule_1.default.pattern(rule, value, source, errors, options);
|
|
17
|
-
if (rule.whitespace === true) {
|
|
18
|
-
rule_1.default.whitespace(rule, value, source, errors, options);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
callback(errors);
|
|
23
|
-
};
|
|
24
|
-
exports.default = string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const rule_1 = require("../rule");
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const type = (rule, value, callback, source, options) => {
|
|
6
|
-
const ruleType = rule.type;
|
|
7
|
-
const errors = [];
|
|
8
|
-
const validate = rule.required || (!rule.required && source.hasOwnProperty(rule.field));
|
|
9
|
-
if (validate) {
|
|
10
|
-
if ((0, util_1.isEmptyValue)(value, ruleType) && !rule.required) {
|
|
11
|
-
return callback();
|
|
12
|
-
}
|
|
13
|
-
rule_1.default.required(rule, value, source, errors, options, ruleType);
|
|
14
|
-
if (!(0, util_1.isEmptyValue)(value, ruleType)) {
|
|
15
|
-
rule_1.default.type(rule, value, source, errors, options);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
callback(errors);
|
|
19
|
-
};
|
|
20
|
-
exports.default = type;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const hook_1 = require("../hook");
|
|
4
|
-
const async_validator_1 = require("./async-validator");
|
|
5
|
-
function validator(rules) {
|
|
6
|
-
return new async_validator_1.default(rules);
|
|
7
|
-
}
|
|
8
|
-
function validate(rules, source_, o = {}, oc = () => { }) {
|
|
9
|
-
return hook_1.default.run(validator(rules).validate(source_, o, oc));
|
|
10
|
-
}
|
|
11
|
-
function validateId(content) {
|
|
12
|
-
if (!content)
|
|
13
|
-
return false;
|
|
14
|
-
if (content.length < 6)
|
|
15
|
-
return false;
|
|
16
|
-
const reg = /^[A-Za-z0-9_-]+$/;
|
|
17
|
-
if (!reg.test(content)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
function validatePhone(content) {
|
|
23
|
-
if (!content)
|
|
24
|
-
return false;
|
|
25
|
-
const reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
26
|
-
if (!reg.test(content)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
function isChinese(content) {
|
|
32
|
-
if (!content)
|
|
33
|
-
return false;
|
|
34
|
-
const reg = /^[\u4E00-\u9FA5]+$/;
|
|
35
|
-
if (!reg.test(content)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
function isNumber(content) {
|
|
41
|
-
if (!content)
|
|
42
|
-
return false;
|
|
43
|
-
const reg = /^[0-9]+$/;
|
|
44
|
-
if (!reg.test(content)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
function isFloat(content) {
|
|
50
|
-
if (!content)
|
|
51
|
-
return false;
|
|
52
|
-
const reg = /^(\-|\+)?\d+(\.\d+)?$/;
|
|
53
|
-
if (!reg.test(content)) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
function isPhoneNumber(content) {
|
|
59
|
-
if (!content)
|
|
60
|
-
return false;
|
|
61
|
-
const reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
62
|
-
if (!reg.test(content)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
exports.default = { validateId, validatePhone, validator, validate, isChinese, isNumber, isFloat, isPhoneNumber };
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const createCaseFirst_1 = require("../../common/internal/createCaseFirst");
|
|
4
|
-
const is_1 = require("../../util/is");
|
|
5
|
-
const words_1 = require("./words");
|
|
6
|
-
const INFINITY = 1 / 0;
|
|
7
|
-
function toString(value) {
|
|
8
|
-
if (value == null) {
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
// Exit early for strings to avoid a performance hit in some environments.
|
|
12
|
-
if (typeof value === 'string') {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
// Recursively convert values (susceptible to call stack limits).
|
|
17
|
-
return `${value.map((other) => (other == null ? other : toString(other)))}`;
|
|
18
|
-
}
|
|
19
|
-
if (is_1.default.isSymbol(value)) {
|
|
20
|
-
return value.toString();
|
|
21
|
-
}
|
|
22
|
-
const result = `${value}`;
|
|
23
|
-
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
|
|
24
|
-
}
|
|
25
|
-
const upperFirst = (0, createCaseFirst_1.default)('toUpperCase');
|
|
26
|
-
const lowerFirst = (0, createCaseFirst_1.default)('toLowerCase');
|
|
27
|
-
const snakeCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '_' : '') + word.toLowerCase(), '');
|
|
28
|
-
const kebabCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '-' : '') + word.toLowerCase(), '');
|
|
29
|
-
const upperCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + word.toUpperCase(), '');
|
|
30
|
-
const camelCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => {
|
|
31
|
-
word = word.toLowerCase();
|
|
32
|
-
return result + (index ? upperFirst(word) : word);
|
|
33
|
-
}, '');
|
|
34
|
-
const lowerCase = (string) => (0, words_1.default)(toString(string).replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase(), '');
|
|
35
|
-
/**
|
|
36
|
-
* startCase('--foo-bar--')
|
|
37
|
-
* // => 'Foo Bar'
|
|
38
|
-
*
|
|
39
|
-
* startCase('fooBar')
|
|
40
|
-
* // => 'Foo Bar'
|
|
41
|
-
*
|
|
42
|
-
* startCase('__FOO_BAR__')
|
|
43
|
-
* // => 'FOO BAR'
|
|
44
|
-
*/
|
|
45
|
-
const startCase = (string) => (0, words_1.default)(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? ' ' : '') + upperFirst(word), '');
|
|
46
|
-
const splitOnFirst = (string, separator) => {
|
|
47
|
-
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
|
48
|
-
throw new TypeError('Expected the arguments to be of type `string`');
|
|
49
|
-
}
|
|
50
|
-
if (string === '' || separator === '') {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const separatorIndex = string.indexOf(separator);
|
|
54
|
-
if (separatorIndex === -1) {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
return [string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length)];
|
|
58
|
-
};
|
|
59
|
-
const parseValue = (value, { number = false, boolean = false } = {}) => {
|
|
60
|
-
let val = value;
|
|
61
|
-
if (!value || typeof value !== 'string')
|
|
62
|
-
return val;
|
|
63
|
-
if (number && !Number.isNaN(Number(value)) && typeof value === 'string' && value.trim() !== '') {
|
|
64
|
-
val = Number(value);
|
|
65
|
-
}
|
|
66
|
-
else if (boolean &&
|
|
67
|
-
value !== null &&
|
|
68
|
-
(value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
|
69
|
-
val = value.toLowerCase() === 'true';
|
|
70
|
-
}
|
|
71
|
-
return val;
|
|
72
|
-
};
|
|
73
|
-
const replace = (source, rules) => {
|
|
74
|
-
if (!source)
|
|
75
|
-
return source;
|
|
76
|
-
if (!rules)
|
|
77
|
-
return source;
|
|
78
|
-
let result = source;
|
|
79
|
-
const _arr = Array.isArray(rules) ? rules : [rules];
|
|
80
|
-
(_arr || []).forEach((e) => {
|
|
81
|
-
if (e.key && e.value) {
|
|
82
|
-
result = result.replace(new RegExp(e.key, e.flag || ''), e.value);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return result;
|
|
86
|
-
};
|
|
87
|
-
const jsonFormat = (jsonString) => {
|
|
88
|
-
try {
|
|
89
|
-
if (!jsonString)
|
|
90
|
-
return '';
|
|
91
|
-
const json = JSON.parse(jsonString);
|
|
92
|
-
return JSON.stringify(json, null, 2);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
return jsonString;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const toLines = (content, separator = '\n') => {
|
|
99
|
-
if (!content)
|
|
100
|
-
return [];
|
|
101
|
-
return content
|
|
102
|
-
.split(separator)
|
|
103
|
-
.map((line) => line.trim())
|
|
104
|
-
.filter((txt) => !!txt);
|
|
105
|
-
};
|
|
106
|
-
exports.default = {
|
|
107
|
-
toString,
|
|
108
|
-
startCase,
|
|
109
|
-
snakeCase,
|
|
110
|
-
kebabCase,
|
|
111
|
-
camelCase,
|
|
112
|
-
upperCase,
|
|
113
|
-
upperFirst,
|
|
114
|
-
lowerCase,
|
|
115
|
-
lowerFirst,
|
|
116
|
-
splitOnFirst,
|
|
117
|
-
parseValue,
|
|
118
|
-
replace,
|
|
119
|
-
jsonFormat,
|
|
120
|
-
toLines,
|
|
121
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const unicodeWords_1 = require("../../common/internal/unicodeWords");
|
|
4
|
-
const hasUnicodeWord = RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/);
|
|
5
|
-
/** Used to match words composed of alphanumeric characters. */
|
|
6
|
-
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
7
|
-
function asciiWords(string) {
|
|
8
|
-
return string.match(reAsciiWord);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Splits `string` into an array of its words.
|
|
12
|
-
*
|
|
13
|
-
* @since 3.0.0
|
|
14
|
-
* @category String
|
|
15
|
-
* @param {string} [string=''] The string to inspect.
|
|
16
|
-
* @param {RegExp|string} [pattern] The pattern to match words.
|
|
17
|
-
* @returns {Array} Returns the words of `string`.
|
|
18
|
-
* @example
|
|
19
|
-
*
|
|
20
|
-
* words('fred, barney, & pebbles')
|
|
21
|
-
* // => ['fred', 'barney', 'pebbles']
|
|
22
|
-
*
|
|
23
|
-
* words('fred, barney, & pebbles', /[^, ]+/g)
|
|
24
|
-
* // => ['fred', 'barney', '&', 'pebbles']
|
|
25
|
-
*/
|
|
26
|
-
function words(string, pattern) {
|
|
27
|
-
if (pattern === undefined) {
|
|
28
|
-
const result = hasUnicodeWord(string) ? (0, unicodeWords_1.default)(string) : asciiWords(string);
|
|
29
|
-
return result || [];
|
|
30
|
-
}
|
|
31
|
-
return string.match(pattern) || [];
|
|
32
|
-
}
|
|
33
|
-
exports.default = words;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/** 1天ms数 */
|
|
4
|
-
const oneDay = 86400000;
|
|
5
|
-
/** 1小时ms数 */
|
|
6
|
-
const oneHour = 3600000;
|
|
7
|
-
/** 1分ms数 */
|
|
8
|
-
const oneMinute = 60000;
|
|
9
|
-
/** 1秒ms数 */
|
|
10
|
-
const oneSecond = 1000;
|
|
11
|
-
exports.default = { oneDay, oneHour, oneMinute, oneSecond };
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const const_1 = require("./const");
|
|
4
|
-
class DTime {
|
|
5
|
-
date;
|
|
6
|
-
timestamp = 0;
|
|
7
|
-
yyyy = 0;
|
|
8
|
-
yy = '';
|
|
9
|
-
M = 0;
|
|
10
|
-
MM = '';
|
|
11
|
-
d = 0;
|
|
12
|
-
dd = '';
|
|
13
|
-
h = 0;
|
|
14
|
-
hh = '';
|
|
15
|
-
m = 0;
|
|
16
|
-
mm = '';
|
|
17
|
-
s = 0;
|
|
18
|
-
ss = '';
|
|
19
|
-
S = 0;
|
|
20
|
-
SS = '';
|
|
21
|
-
SSS = '';
|
|
22
|
-
constructor(time) {
|
|
23
|
-
if (!time)
|
|
24
|
-
return;
|
|
25
|
-
const date = typeof time === 'string' || typeof time === 'number' ? new Date(time) : time;
|
|
26
|
-
if (!date)
|
|
27
|
-
return;
|
|
28
|
-
this.date = date;
|
|
29
|
-
this.timestamp = date.getTime();
|
|
30
|
-
// 默认日期格式
|
|
31
|
-
this.toDate();
|
|
32
|
-
}
|
|
33
|
-
toDate() {
|
|
34
|
-
if (!this.date)
|
|
35
|
-
return this;
|
|
36
|
-
this.yyyy = this.date.getFullYear();
|
|
37
|
-
this.yy = `${this.yyyy}`.substr(2);
|
|
38
|
-
this.M = this.date.getMonth() + 1;
|
|
39
|
-
this.MM = (this.M < 10 ? '0' : '') + this.M;
|
|
40
|
-
this.d = this.date.getDate();
|
|
41
|
-
this.dd = (this.d < 10 ? '0' : '') + this.d;
|
|
42
|
-
this.h = this.date.getHours();
|
|
43
|
-
this.hh = (this.h < 10 ? '0' : '') + this.h;
|
|
44
|
-
this.m = this.date.getMinutes();
|
|
45
|
-
this.mm = (this.m < 10 ? '0' : '') + this.m;
|
|
46
|
-
this.s = this.date.getSeconds();
|
|
47
|
-
this.ss = (this.s < 10 ? '0' : '') + this.s;
|
|
48
|
-
this.S = this.date.getMilliseconds();
|
|
49
|
-
this.SS = (this.S < 10 ? '0' : '') + this.S;
|
|
50
|
-
this.SSS = this.S.toString().padStart(3, '0');
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
toCountdown(regFormat = '') {
|
|
54
|
-
const result = {
|
|
55
|
-
countdown: 0,
|
|
56
|
-
timestamp: 0,
|
|
57
|
-
seconds: 0,
|
|
58
|
-
d: 0,
|
|
59
|
-
dd: '',
|
|
60
|
-
h: 0,
|
|
61
|
-
hh: '',
|
|
62
|
-
m: 0,
|
|
63
|
-
mm: '',
|
|
64
|
-
s: 0,
|
|
65
|
-
ss: '',
|
|
66
|
-
S: 0,
|
|
67
|
-
SS: '',
|
|
68
|
-
SSS: '',
|
|
69
|
-
desc: '',
|
|
70
|
-
};
|
|
71
|
-
if (!this.timestamp)
|
|
72
|
-
return result;
|
|
73
|
-
result.timestamp = this.timestamp;
|
|
74
|
-
result.countdown = Math.max(result.timestamp - Date.now(), 0);
|
|
75
|
-
result.seconds = Math.floor(result.countdown / const_1.default.oneSecond);
|
|
76
|
-
let amount = result.countdown;
|
|
77
|
-
result.d = Math.floor(amount / const_1.default.oneDay);
|
|
78
|
-
result.dd = (result.d < 10 ? '0' : '') + result.d;
|
|
79
|
-
amount = amount % const_1.default.oneDay;
|
|
80
|
-
result.h = Math.floor(amount / const_1.default.oneHour);
|
|
81
|
-
result.hh = (result.h < 10 ? '0' : '') + result.h;
|
|
82
|
-
amount = amount % const_1.default.oneHour;
|
|
83
|
-
result.m = Math.floor(amount / const_1.default.oneMinute);
|
|
84
|
-
result.mm = (result.m < 10 ? '0' : '') + result.m;
|
|
85
|
-
amount = amount % const_1.default.oneMinute;
|
|
86
|
-
result.s = Math.floor(amount / const_1.default.oneSecond);
|
|
87
|
-
result.ss = (result.s < 10 ? '0' : '') + result.s;
|
|
88
|
-
amount = amount % const_1.default.oneSecond;
|
|
89
|
-
result.S = amount;
|
|
90
|
-
result.SS = (result.S < 10 ? '0' : '') + result.S;
|
|
91
|
-
result.SSS = result.S.toString().padStart(3, '0');
|
|
92
|
-
let _reg = regFormat;
|
|
93
|
-
if (!_reg) {
|
|
94
|
-
if (result.countdown > const_1.default.oneHour) {
|
|
95
|
-
_reg = 'hh:mm:ss';
|
|
96
|
-
}
|
|
97
|
-
else if (result.countdown > const_1.default.oneMinute) {
|
|
98
|
-
_reg = 'mm:ss';
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
_reg = 'ss';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
result.desc = _reg.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g, ($1) => result[$1]);
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
add(ms = 0) {
|
|
108
|
-
if (!ms)
|
|
109
|
-
return this;
|
|
110
|
-
this.timestamp = this.timestamp + ms;
|
|
111
|
-
this.date = new Date(this.timestamp);
|
|
112
|
-
this.toDate();
|
|
113
|
-
return this;
|
|
114
|
-
}
|
|
115
|
-
format(reg = 'yyyy-MM-dd hh:mm:ss') {
|
|
116
|
-
return reg.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g, ($1) => this[$1]);
|
|
117
|
-
}
|
|
118
|
-
static get timezoneOffset() {
|
|
119
|
-
return new Date().getTimezoneOffset() / 60;
|
|
120
|
-
}
|
|
121
|
-
static getLocalTime(timezoneOffset = 0) {
|
|
122
|
-
const d = new Date();
|
|
123
|
-
//得到1970年一月一日到现在的秒数
|
|
124
|
-
const t = d.getTime();
|
|
125
|
-
//本地时间与GMT时间的时间偏移差(注意:GMT这是UTC的民间名称。GMT=UTC)
|
|
126
|
-
const offset = d.getTimezoneOffset() * 60000;
|
|
127
|
-
//得到现在的格林尼治时间
|
|
128
|
-
const utcTime = t + offset;
|
|
129
|
-
return new Date(utcTime + 3600000 * timezoneOffset);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.default = DTime;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const event_1 = require("../../class/event");
|
|
4
|
-
class DLoopFrame {
|
|
5
|
-
_loopTimer;
|
|
6
|
-
_event = new event_1.default();
|
|
7
|
-
started = false;
|
|
8
|
-
interval = 0;
|
|
9
|
-
constructor(interval = 0) {
|
|
10
|
-
this.interval = interval || 500;
|
|
11
|
-
}
|
|
12
|
-
start() {
|
|
13
|
-
if (this.started)
|
|
14
|
-
return this;
|
|
15
|
-
this.stop();
|
|
16
|
-
this._loopTimer = setInterval(() => {
|
|
17
|
-
this._handleLoop();
|
|
18
|
-
}, this.interval);
|
|
19
|
-
this.started = true;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
stop() {
|
|
23
|
-
if (!this._loopTimer)
|
|
24
|
-
return this;
|
|
25
|
-
clearInterval(this._loopTimer);
|
|
26
|
-
this._loopTimer = 0;
|
|
27
|
-
this.started = false;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
restart() {
|
|
31
|
-
this.stop();
|
|
32
|
-
this.start();
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
on(cb) {
|
|
36
|
-
this._event.on("frame", cb);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
off(cb) {
|
|
40
|
-
if (!cb)
|
|
41
|
-
return this;
|
|
42
|
-
this._event.off("frame", cb);
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
_handleLoop() {
|
|
46
|
-
this._event.emit("frame");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.default = DLoopFrame;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const frame_1 = require("./frame");
|
|
4
|
-
const dtime_1 = require("./dtime");
|
|
5
|
-
const const_1 = require("./const");
|
|
6
|
-
/**
|
|
7
|
-
* 是否是今天
|
|
8
|
-
* @param {*} date
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
const isToday = (date) => date && new Date().toDateString() === new Date(date).toDateString();
|
|
12
|
-
/**
|
|
13
|
-
* 当天零点
|
|
14
|
-
*/
|
|
15
|
-
const todayZero = () => parseTimestamp({}); // new Date(format(Date.now(), "yyyy/MM/dd 00:00:00")).getTime();
|
|
16
|
-
/**
|
|
17
|
-
* 时间格式化
|
|
18
|
-
* @param {string|number|Date} time
|
|
19
|
-
* @param {string} reg "yyyyMMdd hhmmss"
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
const format = (time, reg = 'yyyy-MM-dd hh:mm:ss') => {
|
|
23
|
-
const date = typeof time === 'string' || typeof time === 'number' ? new Date(time) : time;
|
|
24
|
-
if (!date)
|
|
25
|
-
return '';
|
|
26
|
-
return dtime(date).format(reg);
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param time 时间戳|日期时间字符串|Date
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
const dtime = (time) => {
|
|
34
|
-
const date = typeof time === 'string' || typeof time === 'number' ? new Date(time) : time;
|
|
35
|
-
if (!date)
|
|
36
|
-
return new dtime_1.default(0);
|
|
37
|
-
return new dtime_1.default(date);
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* 解析时间
|
|
41
|
-
* @param param0
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
function parseTimestamp({ year = 0, month = 0, date = 0, hour = 0, minute = 0, second = 0 }) {
|
|
45
|
-
const _format = `${year || 'yyyy'}/${month || 'MM'}/${date || 'dd'} ${hour}:${minute}:${second}`;
|
|
46
|
-
return new Date(format(Date.now(), _format)).getTime();
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 当前时间格式类
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
function now() {
|
|
53
|
-
return dtime(new Date());
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 倒计时格式
|
|
57
|
-
* @param endTime 结束时间
|
|
58
|
-
* @param reg 格式
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
const countdown = (endTime, reg = '') => {
|
|
62
|
-
const date = typeof endTime === 'string' || typeof endTime === 'number' ? new Date(endTime) : endTime;
|
|
63
|
-
if (!date)
|
|
64
|
-
return '';
|
|
65
|
-
const map = dtime(date);
|
|
66
|
-
return map.toCountdown(reg);
|
|
67
|
-
};
|
|
68
|
-
const loopFrame = (interval = 500) => {
|
|
69
|
-
return new frame_1.default(interval);
|
|
70
|
-
};
|
|
71
|
-
const getTimezoneOffset = () => dtime_1.default.timezoneOffset;
|
|
72
|
-
exports.default = {
|
|
73
|
-
...const_1.default,
|
|
74
|
-
now,
|
|
75
|
-
isToday,
|
|
76
|
-
parseTimestamp,
|
|
77
|
-
todayZero,
|
|
78
|
-
format,
|
|
79
|
-
countdown,
|
|
80
|
-
dtime,
|
|
81
|
-
loopFrame,
|
|
82
|
-
getTimezoneOffset,
|
|
83
|
-
getLocalTime: dtime_1.default.getLocalTime,
|
|
84
|
-
};
|
package/bin/lib/typings/index.js
DELETED
package/bin/lib/util/function.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getset_1 = require("../class/getset");
|
|
4
|
-
/**
|
|
5
|
-
* 设置单例模式
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
function singleton() {
|
|
9
|
-
class Singleton {
|
|
10
|
-
static __instance__;
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
|
-
constructor() { }
|
|
13
|
-
static get Instance() {
|
|
14
|
-
if (!Singleton.__instance__) {
|
|
15
|
-
Singleton.__instance__ = new this();
|
|
16
|
-
}
|
|
17
|
-
return Singleton.__instance__;
|
|
18
|
-
}
|
|
19
|
-
static get I() {
|
|
20
|
-
return this.Instance;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return Singleton;
|
|
24
|
-
}
|
|
25
|
-
function getset(t) {
|
|
26
|
-
const result = new getset_1.default();
|
|
27
|
-
// 初始化
|
|
28
|
-
if (t !== undefined) {
|
|
29
|
-
result.set(t);
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
exports.default = { singleton, getset };
|