@zwa73/utils 1.0.205 → 1.0.207

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 (48) hide show
  1. package/dist/QuickExport.d.ts +1 -2
  2. package/dist/QuickExport.js +27 -22
  3. package/dist/UtilClass.d.ts +1 -98
  4. package/dist/UtilClass.js +5 -242
  5. package/dist/UtilCom.d.ts +1 -1
  6. package/dist/UtilDecorators.d.ts +1 -32
  7. package/dist/UtilDecorators.js +15 -225
  8. package/dist/UtilFunctions.d.ts +9 -267
  9. package/dist/UtilFunctions.js +38 -687
  10. package/dist/UtilI18n.js +1 -1
  11. package/dist/UtilInterfaces.d.ts +1 -180
  12. package/dist/UtilInterfaces.js +1 -0
  13. package/dist/UtilLogger.d.ts +19 -20
  14. package/dist/UtilLogger.js +1 -1
  15. package/dist/UtilSymbol.d.ts +1 -40
  16. package/dist/UtilSymbol.js +11 -27
  17. package/dist/index.js +3 -0
  18. package/dist/test/dist/bitcont.d.ts +1 -0
  19. package/dist/test/dist/bitcont.js +153 -0
  20. package/dist/test/dist/error.d.ts +1 -0
  21. package/dist/test/dist/error.js +11 -0
  22. package/dist/test/dist/fptest.d.ts +1 -0
  23. package/dist/test/dist/fptest.js +21 -0
  24. package/dist/test/dist/hbs.d.ts +1 -0
  25. package/dist/test/dist/hbs.js +14 -0
  26. package/dist/test/dist/ip.d.ts +1 -0
  27. package/dist/test/dist/ip.js +107 -0
  28. package/dist/test/dist/llonebot.d.ts +0 -0
  29. package/dist/test/dist/llonebot.js +1 -0
  30. package/dist/test/dist/log.d.ts +1 -0
  31. package/dist/test/dist/log.js +9 -0
  32. package/dist/test/dist/match.d.ts +1 -0
  33. package/dist/test/dist/match.js +19 -0
  34. package/dist/test/dist/pathe.d.ts +1 -0
  35. package/dist/test/dist/pathe.js +7 -0
  36. package/dist/test/dist/queuetest.d.ts +1 -0
  37. package/dist/test/dist/queuetest.js +139 -0
  38. package/dist/test/dist/regtest.d.ts +1 -0
  39. package/dist/test/dist/regtest.js +8 -0
  40. package/dist/test/dist/repeatTest.d.ts +1 -0
  41. package/dist/test/dist/repeatTest.js +120 -0
  42. package/dist/test/dist/stringifytest.d.ts +1 -0
  43. package/dist/test/dist/stringifytest.js +8 -0
  44. package/dist/test/dist/test2.d.ts +1 -0
  45. package/dist/test/dist/test2.js +35 -0
  46. package/dist/test/dist/testStream.d.ts +1 -0
  47. package/dist/test/dist/testStream.js +286 -0
  48. package/package.json +3 -1
@@ -0,0 +1,107 @@
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 {
6
+ step(generator.next(value));
7
+ }
8
+ catch (e) {
9
+ reject(e);
10
+ } }
11
+ function rejected(value) { try {
12
+ step(generator["throw"](value));
13
+ }
14
+ catch (e) {
15
+ reject(e);
16
+ } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
23
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f)
28
+ throw new TypeError("Generator is already executing.");
29
+ while (_)
30
+ try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
32
+ return t;
33
+ if (y = 0, t)
34
+ op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0:
37
+ case 1:
38
+ t = op;
39
+ break;
40
+ case 4:
41
+ _.label++;
42
+ return { value: op[1], done: false };
43
+ case 5:
44
+ _.label++;
45
+ y = op[1];
46
+ op = [0];
47
+ continue;
48
+ case 7:
49
+ op = _.ops.pop();
50
+ _.trys.pop();
51
+ continue;
52
+ default:
53
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
54
+ _ = 0;
55
+ continue;
56
+ }
57
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
58
+ _.label = op[1];
59
+ break;
60
+ }
61
+ if (op[0] === 6 && _.label < t[1]) {
62
+ _.label = t[1];
63
+ t = op;
64
+ break;
65
+ }
66
+ if (t && _.label < t[2]) {
67
+ _.label = t[2];
68
+ _.ops.push(op);
69
+ break;
70
+ }
71
+ if (t[2])
72
+ _.ops.pop();
73
+ _.trys.pop();
74
+ continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ }
78
+ catch (e) {
79
+ op = [6, e];
80
+ y = 0;
81
+ }
82
+ finally {
83
+ f = t = 0;
84
+ }
85
+ if (op[0] & 5)
86
+ throw op[1];
87
+ return { value: op[0] ? op[1] : void 0, done: true };
88
+ }
89
+ };
90
+ exports.__esModule = true;
91
+ var __1 = require("..");
92
+ function main() {
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var _a, _b;
95
+ return __generator(this, function (_c) {
96
+ switch (_c.label) {
97
+ case 0:
98
+ _b = (_a = console).log;
99
+ return [4 /*yield*/, __1.UtilFunc.getPublicIpv4()];
100
+ case 1:
101
+ _b.apply(_a, [_c.sent()]);
102
+ return [2 /*return*/];
103
+ }
104
+ });
105
+ });
106
+ }
107
+ main();
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ JSON.stringify({
4
+ "code": 0,
5
+ "message": "操作成功",
6
+ "data": {
7
+ "url": "wss://nws.kaiheila.cn/gateway?compress=0&token=M2tKMndvcTVzUU1GeEtYM3E5V2hZUSsrdHhycVVVcWhwcDRLSUxOWVFwL3N3dGVEblh1UTBjL0tVVVYzekhqeGZ1NlNyRUpLME11azFDR3RIdk5kL0pkZHhrMHUxNHZqMUZzOUxyc2ozTjcxR3lkRENuR2dTdHBJQjlkakhiUUxldm13MW5uT3hJdjJ6eUsyRjFPZ2N3PT0="
8
+ }
9
+ }, null, 2); //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var _a;
3
+ exports.__esModule = true;
4
+ var QuickExport_1 = require("../QuickExport");
5
+ var UtilFunctions_1 = require("../UtilFunctions");
6
+ var UtilSymbol_1 = require("../UtilSymbol");
7
+ function test() {
8
+ return 1;
9
+ }
10
+ var etest = UtilFunctions_1.UtilFunc.eitherize(test);
11
+ var res = etest();
12
+ QuickExport_1.matchProc(res, (_a = {},
13
+ _a[UtilSymbol_1.Success] = function (status, res) {
14
+ console.log(res);
15
+ },
16
+ _a[UtilSymbol_1.Failed] = function (status, res) {
17
+ console.error(res);
18
+ },
19
+ _a));
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var pathe_1 = require("pathe");
4
+ var path_1 = require("path");
5
+ pathe_1["default"].join(process.cwd(), '/1/2/3'); //?
6
+ pathe_1["default"].relative(process.cwd(), "F:/"); //?
7
+ path_1["default"].relative(process.cwd(), "F:/"); //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,139 @@
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 {
6
+ step(generator.next(value));
7
+ }
8
+ catch (e) {
9
+ reject(e);
10
+ } }
11
+ function rejected(value) { try {
12
+ step(generator["throw"](value));
13
+ }
14
+ catch (e) {
15
+ reject(e);
16
+ } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
23
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f)
28
+ throw new TypeError("Generator is already executing.");
29
+ while (_)
30
+ try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
32
+ return t;
33
+ if (y = 0, t)
34
+ op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0:
37
+ case 1:
38
+ t = op;
39
+ break;
40
+ case 4:
41
+ _.label++;
42
+ return { value: op[1], done: false };
43
+ case 5:
44
+ _.label++;
45
+ y = op[1];
46
+ op = [0];
47
+ continue;
48
+ case 7:
49
+ op = _.ops.pop();
50
+ _.trys.pop();
51
+ continue;
52
+ default:
53
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
54
+ _ = 0;
55
+ continue;
56
+ }
57
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
58
+ _.label = op[1];
59
+ break;
60
+ }
61
+ if (op[0] === 6 && _.label < t[1]) {
62
+ _.label = t[1];
63
+ t = op;
64
+ break;
65
+ }
66
+ if (t && _.label < t[2]) {
67
+ _.label = t[2];
68
+ _.ops.push(op);
69
+ break;
70
+ }
71
+ if (t[2])
72
+ _.ops.pop();
73
+ _.trys.pop();
74
+ continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ }
78
+ catch (e) {
79
+ op = [6, e];
80
+ y = 0;
81
+ }
82
+ finally {
83
+ f = t = 0;
84
+ }
85
+ if (op[0] & 5)
86
+ throw op[1];
87
+ return { value: op[0] ? op[1] : void 0, done: true };
88
+ }
89
+ };
90
+ exports.__esModule = true;
91
+ var __1 = require("..");
92
+ var QueueProcessor = /** @class */ (function () {
93
+ function QueueProcessor() {
94
+ }
95
+ QueueProcessor.queueProc = function (flag, task) {
96
+ var _this = this;
97
+ if (!this.pendingMap[flag])
98
+ this.pendingMap[flag] = [];
99
+ var resolveFunc;
100
+ var promise = new Promise(function (resolve) {
101
+ resolveFunc = resolve;
102
+ });
103
+ var processTask = function () {
104
+ return __awaiter(_this, void 0, void 0, function () {
105
+ var result, error_1;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0:
109
+ _a.trys.push([0, 2, 3, 4]);
110
+ return [4 /*yield*/, task()];
111
+ case 1:
112
+ result = _a.sent();
113
+ resolveFunc(result);
114
+ return [3 /*break*/, 4];
115
+ case 2:
116
+ error_1 = _a.sent();
117
+ __1.SLogger.warn("queueProc \u9519\u8BEF: ", error_1, "flag: " + String(flag));
118
+ return [3 /*break*/, 4];
119
+ case 3:
120
+ this.pendingMap[flag].shift();
121
+ if (this.pendingMap[flag].length > 0) {
122
+ this.pendingMap[flag][0]();
123
+ }
124
+ else
125
+ delete this.pendingMap[flag];
126
+ return [7 /*endfinally*/];
127
+ case 4: return [2 /*return*/];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ this.pendingMap[flag].push(processTask);
133
+ if (this.pendingMap[flag].length === 1)
134
+ processTask();
135
+ return promise;
136
+ };
137
+ QueueProcessor.pendingMap = {};
138
+ return QueueProcessor;
139
+ }());
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var __1 = require("..");
4
+ var list = ["ext\\abc\\asd.png"];
5
+ var newPath = list[0].replace(/ext\\([^\\]+?)\\([^\\]+?)\.png/, "map/$2.png"); //?
6
+ __1.UtilFT.fileSearchRegex(__dirname, '.*'); //?
7
+ 12; //?
8
+ console.log(__1.UtilFunc.getFuncLoc());
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,120 @@
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 {
6
+ step(generator.next(value));
7
+ }
8
+ catch (e) {
9
+ reject(e);
10
+ } }
11
+ function rejected(value) { try {
12
+ step(generator["throw"](value));
13
+ }
14
+ catch (e) {
15
+ reject(e);
16
+ } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
23
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f)
28
+ throw new TypeError("Generator is already executing.");
29
+ while (_)
30
+ try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
32
+ return t;
33
+ if (y = 0, t)
34
+ op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0:
37
+ case 1:
38
+ t = op;
39
+ break;
40
+ case 4:
41
+ _.label++;
42
+ return { value: op[1], done: false };
43
+ case 5:
44
+ _.label++;
45
+ y = op[1];
46
+ op = [0];
47
+ continue;
48
+ case 7:
49
+ op = _.ops.pop();
50
+ _.trys.pop();
51
+ continue;
52
+ default:
53
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
54
+ _ = 0;
55
+ continue;
56
+ }
57
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
58
+ _.label = op[1];
59
+ break;
60
+ }
61
+ if (op[0] === 6 && _.label < t[1]) {
62
+ _.label = t[1];
63
+ t = op;
64
+ break;
65
+ }
66
+ if (t && _.label < t[2]) {
67
+ _.label = t[2];
68
+ _.ops.push(op);
69
+ break;
70
+ }
71
+ if (t[2])
72
+ _.ops.pop();
73
+ _.trys.pop();
74
+ continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ }
78
+ catch (e) {
79
+ op = [6, e];
80
+ y = 0;
81
+ }
82
+ finally {
83
+ f = t = 0;
84
+ }
85
+ if (op[0] & 5)
86
+ throw op[1];
87
+ return { value: op[0] ? op[1] : void 0, done: true };
88
+ }
89
+ };
90
+ exports.__esModule = true;
91
+ var __1 = require("..");
92
+ // 模拟的异步函数,有一定几率失败
93
+ function mockAsyncFunction() {
94
+ return __awaiter(this, void 0, Promise, function () {
95
+ return __generator(this, function (_a) {
96
+ return [2 /*return*/, new Promise(function (resolve, reject) {
97
+ setTimeout(function () {
98
+ Math.random() > 0.5 ? resolve("Success") : reject("Failure");
99
+ }, Math.random() % 2000);
100
+ })];
101
+ });
102
+ });
103
+ }
104
+ // 验证函数,只有当结果为 "Success" 时才认为成功
105
+ function mockVerifyFunction(result) {
106
+ return result === "Success" ? __1.Success : __1.Failed;
107
+ }
108
+ // 测试 retryPromise 函数
109
+ __1.UtilFunc.retryPromise(mockAsyncFunction, mockVerifyFunction)
110
+ .then(function (result) {
111
+ console.log("then");
112
+ if (result === null) {
113
+ console.log("全部超时");
114
+ }
115
+ else {
116
+ console.log("成功:", result);
117
+ }
118
+ })["catch"](function (err) {
119
+ console.error("出现错误", err);
120
+ });
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var __1 = require("..");
4
+ var json = {
5
+ a: { b: 123 }
6
+ };
7
+ console.log(__1.UtilFunc.stringifyJToken(json, { compress: true }));
8
+ console.log(__1.UtilFunc.stringifyJToken(json));
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var pathe_1 = require("pathe");
4
+ var UtilFileTools_1 = require("../../UtilFileTools");
5
+ // 将字符串转换为十六进制
6
+ function stringToHex(str) {
7
+ var buf = Buffer.from(str, 'utf8');
8
+ return buf.toString('hex');
9
+ }
10
+ // 将十六进制转换为字符串
11
+ function hexToString(hex) {
12
+ var buf = Buffer.from(hex, 'hex');
13
+ return buf.toString('utf8');
14
+ }
15
+ // 示例
16
+ var str = "Hello World";
17
+ var hex = "0B0000002D";
18
+ console.log(stringToHex(str)); // 输出字符串对应的十六进制
19
+ console.log(hexToString(hex)); // 输出十六进制对应的字符串
20
+ hexToString("556E6974794653"); //?
21
+ /**
22
+ 首先我有一个文件夹./in
23
+ 我在里面存放了一些整合加密的二进制文件,文件名符合正则/.*\.bk/
24
+ 我需要你帮我写解密程序,将其解密并分离为单独的文件,接下来我告诉你解密方式:
25
+ 读取文件后,我们先用split(hexToString(hex))对文本进行分割成多块,然后在每一块找到第二个"UnityFS",
26
+ 再从第二个UnityFS的开头截取到每一块的末尾
27
+ 我举一个例子,假设我们有一段分割完成的文本块 "112233 UnityFS sasasd UnityFS我需要的内容"
28
+ 那么它截取完成之后应该是"UnityFS我需要的内容"
29
+ 最后,我们在将所有截取完成的文本块作为文件输出到./out/{filename}
30
+ 文件名就是 {原文件名+块编号.bs}
31
+ 开始写吧
32
+ **/
33
+ pathe_1["default"].parse("123.bs").name; //?
34
+ var filepath = "F:\\Sosarciel\\SosarcielCore\\NodeJs\\utils\\src";
35
+ UtilFileTools_1.UtilFT.fileSearchGlob(filepath + "/**/*.ts", "**/test/**/*.ts"); //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;