@zwa73/utils 1.0.209 → 1.0.211
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/QuickExport.d.ts +2 -1
- package/dist/QuickExport.js +4 -2
- package/dist/UtilCom.js +1 -1
- package/dist/UtilDecorators.d.ts +1 -1
- package/dist/UtilDecorators.js +3 -11
- package/dist/UtilFP.d.ts +2 -120
- package/dist/UtilFP.js +2 -79
- package/dist/UtilFileTools.d.ts +4 -2
- package/dist/UtilFileTools.js +7 -7
- package/dist/UtilFunctions.d.ts +2 -8
- package/dist/UtilFunctions.js +7 -18
- package/dist/UtilInterfaces.d.ts +1 -1
- package/dist/index.js +15 -1
- package/package.json +1 -1
- package/dist/test/dist/bitcont.d.ts +0 -1
- package/dist/test/dist/bitcont.js +0 -153
- package/dist/test/dist/error.d.ts +0 -1
- package/dist/test/dist/error.js +0 -11
- package/dist/test/dist/fptest.d.ts +0 -1
- package/dist/test/dist/fptest.js +0 -21
- package/dist/test/dist/hbs.d.ts +0 -1
- package/dist/test/dist/hbs.js +0 -14
- package/dist/test/dist/ip.d.ts +0 -1
- package/dist/test/dist/ip.js +0 -107
- package/dist/test/dist/llonebot.d.ts +0 -0
- package/dist/test/dist/llonebot.js +0 -1
- package/dist/test/dist/log.d.ts +0 -1
- package/dist/test/dist/log.js +0 -9
- package/dist/test/dist/match.d.ts +0 -1
- package/dist/test/dist/match.js +0 -19
- package/dist/test/dist/pathe.d.ts +0 -1
- package/dist/test/dist/pathe.js +0 -7
- package/dist/test/dist/queuetest.d.ts +0 -1
- package/dist/test/dist/queuetest.js +0 -139
- package/dist/test/dist/regtest.d.ts +0 -1
- package/dist/test/dist/regtest.js +0 -8
- package/dist/test/dist/repeatTest.d.ts +0 -1
- package/dist/test/dist/repeatTest.js +0 -120
- package/dist/test/dist/stringifytest.d.ts +0 -1
- package/dist/test/dist/stringifytest.js +0 -8
- package/dist/test/dist/test2.d.ts +0 -1
- package/dist/test/dist/test2.js +0 -35
- package/dist/test/dist/testStream.d.ts +0 -1
- package/dist/test/dist/testStream.js +0 -286
package/dist/test/dist/test2.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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"); //?
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const __esModule: true;
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b)
|
|
7
|
-
if (b.hasOwnProperty(p))
|
|
8
|
-
d[p] = b[p]; };
|
|
9
|
-
return extendStatics(d, b);
|
|
10
|
-
};
|
|
11
|
-
return function (d, b) {
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try {
|
|
21
|
-
step(generator.next(value));
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
} }
|
|
26
|
-
function rejected(value) { try {
|
|
27
|
-
step(generator["throw"](value));
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
} }
|
|
32
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
38
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f)
|
|
43
|
-
throw new TypeError("Generator is already executing.");
|
|
44
|
-
while (_)
|
|
45
|
-
try {
|
|
46
|
-
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)
|
|
47
|
-
return t;
|
|
48
|
-
if (y = 0, t)
|
|
49
|
-
op = [op[0] & 2, t.value];
|
|
50
|
-
switch (op[0]) {
|
|
51
|
-
case 0:
|
|
52
|
-
case 1:
|
|
53
|
-
t = op;
|
|
54
|
-
break;
|
|
55
|
-
case 4:
|
|
56
|
-
_.label++;
|
|
57
|
-
return { value: op[1], done: false };
|
|
58
|
-
case 5:
|
|
59
|
-
_.label++;
|
|
60
|
-
y = op[1];
|
|
61
|
-
op = [0];
|
|
62
|
-
continue;
|
|
63
|
-
case 7:
|
|
64
|
-
op = _.ops.pop();
|
|
65
|
-
_.trys.pop();
|
|
66
|
-
continue;
|
|
67
|
-
default:
|
|
68
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
69
|
-
_ = 0;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
73
|
-
_.label = op[1];
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
77
|
-
_.label = t[1];
|
|
78
|
-
t = op;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
if (t && _.label < t[2]) {
|
|
82
|
-
_.label = t[2];
|
|
83
|
-
_.ops.push(op);
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
if (t[2])
|
|
87
|
-
_.ops.pop();
|
|
88
|
-
_.trys.pop();
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
op = body.call(thisArg, _);
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
op = [6, e];
|
|
95
|
-
y = 0;
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
f = t = 0;
|
|
99
|
-
}
|
|
100
|
-
if (op[0] & 5)
|
|
101
|
-
throw op[1];
|
|
102
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
106
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
107
|
-
s += arguments[i].length;
|
|
108
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
109
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
110
|
-
r[k] = a[j];
|
|
111
|
-
return r;
|
|
112
|
-
};
|
|
113
|
-
exports.__esModule = true;
|
|
114
|
-
var __1 = require("../");
|
|
115
|
-
/**并行流 */
|
|
116
|
-
var TStream = /** @class */ (function (_super) {
|
|
117
|
-
__extends(TStream, _super);
|
|
118
|
-
function TStream(base, concurrent) {
|
|
119
|
-
if (concurrent === void 0) {
|
|
120
|
-
concurrent = 1;
|
|
121
|
-
}
|
|
122
|
-
var _this = this;
|
|
123
|
-
/**加工函数列表*/
|
|
124
|
-
_this._operation = [];
|
|
125
|
-
if (base == undefined)
|
|
126
|
-
_this = _super.call(this) || this;
|
|
127
|
-
else if (typeof base === 'number')
|
|
128
|
-
_this = _super.call(this, base) || this;
|
|
129
|
-
else
|
|
130
|
-
_this = _super.apply(this, base) || this;
|
|
131
|
-
_this._concurrent = concurrent;
|
|
132
|
-
return _this;
|
|
133
|
-
}
|
|
134
|
-
/**平分数组
|
|
135
|
-
* @param count - 份数
|
|
136
|
-
* @param mode - 模式 average:轮询平均分 chunk:切块均分
|
|
137
|
-
* @returns 新数组
|
|
138
|
-
*/
|
|
139
|
-
TStream.prototype.divide = function (count, mode) {
|
|
140
|
-
var _this = this;
|
|
141
|
-
if (mode === void 0) {
|
|
142
|
-
mode = "average";
|
|
143
|
-
}
|
|
144
|
-
if (count <= 0)
|
|
145
|
-
return [];
|
|
146
|
-
if (count == 1)
|
|
147
|
-
return [__spreadArrays(this)];
|
|
148
|
-
var size = this.length;
|
|
149
|
-
var result = [];
|
|
150
|
-
__1.matchProc(mode, {
|
|
151
|
-
//轮询平均分
|
|
152
|
-
'average': function () {
|
|
153
|
-
for (var i = 0; i < count; i++) {
|
|
154
|
-
var clist = [];
|
|
155
|
-
for (var j = i; j < size; j += count)
|
|
156
|
-
clist.push(_this[j]);
|
|
157
|
-
result.push(clist);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
//切块均分
|
|
161
|
-
'chunk': function () {
|
|
162
|
-
var chunkSize = Math.ceil(size / count);
|
|
163
|
-
for (var i = 0; i < count; i++) {
|
|
164
|
-
var start = i * chunkSize;
|
|
165
|
-
var end = (i + 1) * chunkSize;
|
|
166
|
-
if (end > size)
|
|
167
|
-
end = size;
|
|
168
|
-
result.push(_this.slice(start, end));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
/**流映射加工
|
|
175
|
-
* @param operation - 加工函数
|
|
176
|
-
* @returns 新流
|
|
177
|
-
*/
|
|
178
|
-
TStream.prototype.stmMap = function (operation) {
|
|
179
|
-
this._operation.push(operation);
|
|
180
|
-
return this;
|
|
181
|
-
};
|
|
182
|
-
/**流遍历
|
|
183
|
-
* 返回自身
|
|
184
|
-
* @param operation - 遍历函数
|
|
185
|
-
* @returns 自身
|
|
186
|
-
*/
|
|
187
|
-
TStream.prototype.stmEach = function (operation) {
|
|
188
|
-
var _this = this;
|
|
189
|
-
var opera = function (item) {
|
|
190
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
191
|
-
return __generator(this, function (_a) {
|
|
192
|
-
operation(item);
|
|
193
|
-
return [2 /*return*/, item];
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
this._operation.push(opera);
|
|
198
|
-
return this;
|
|
199
|
-
};
|
|
200
|
-
//终结操作
|
|
201
|
-
/**应用加工
|
|
202
|
-
* @returns 自身
|
|
203
|
-
*/
|
|
204
|
-
TStream.prototype.stmAppend = function () {
|
|
205
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
206
|
-
var promiseList, sliceList, _loop_1, i, nlist, result, i, subList, subSize, j;
|
|
207
|
-
var _this = this;
|
|
208
|
-
return __generator(this, function (_a) {
|
|
209
|
-
switch (_a.label) {
|
|
210
|
-
case 0:
|
|
211
|
-
if (this._operation.length == 0)
|
|
212
|
-
return [2 /*return*/, this];
|
|
213
|
-
promiseList = [];
|
|
214
|
-
sliceList = this.divide(this._concurrent);
|
|
215
|
-
_loop_1 = function (i) {
|
|
216
|
-
var subList = sliceList[i];
|
|
217
|
-
if (!subList)
|
|
218
|
-
return "continue";
|
|
219
|
-
promiseList.push(new Promise(function (reslove) {
|
|
220
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
221
|
-
var result, _i, subList_1, item, _a, _b, operation;
|
|
222
|
-
return __generator(this, function (_c) {
|
|
223
|
-
switch (_c.label) {
|
|
224
|
-
case 0:
|
|
225
|
-
result = [];
|
|
226
|
-
_i = 0, subList_1 = subList;
|
|
227
|
-
_c.label = 1;
|
|
228
|
-
case 1:
|
|
229
|
-
if (!(_i < subList_1.length))
|
|
230
|
-
return [3 /*break*/, 7];
|
|
231
|
-
item = subList_1[_i];
|
|
232
|
-
if (!item)
|
|
233
|
-
return [3 /*break*/, 6];
|
|
234
|
-
_a = 0, _b = this._operation;
|
|
235
|
-
_c.label = 2;
|
|
236
|
-
case 2:
|
|
237
|
-
if (!(_a < _b.length))
|
|
238
|
-
return [3 /*break*/, 5];
|
|
239
|
-
operation = _b[_a];
|
|
240
|
-
return [4 /*yield*/, operation(item)];
|
|
241
|
-
case 3:
|
|
242
|
-
item = _c.sent();
|
|
243
|
-
_c.label = 4;
|
|
244
|
-
case 4:
|
|
245
|
-
_a++;
|
|
246
|
-
return [3 /*break*/, 2];
|
|
247
|
-
case 5:
|
|
248
|
-
result.push(item);
|
|
249
|
-
_c.label = 6;
|
|
250
|
-
case 6:
|
|
251
|
-
_i++;
|
|
252
|
-
return [3 /*break*/, 1];
|
|
253
|
-
case 7:
|
|
254
|
-
reslove(result);
|
|
255
|
-
return [2 /*return*/];
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
}));
|
|
260
|
-
};
|
|
261
|
-
for (i = 0; i < this._concurrent; i++) {
|
|
262
|
-
_loop_1(i);
|
|
263
|
-
}
|
|
264
|
-
return [4 /*yield*/, Promise.all(promiseList)];
|
|
265
|
-
case 1:
|
|
266
|
-
nlist = _a.sent();
|
|
267
|
-
result = new Array(this.length).fill(undefined);
|
|
268
|
-
for (i = 0; i < this._concurrent; i++) {
|
|
269
|
-
subList = nlist[i];
|
|
270
|
-
if (!subList)
|
|
271
|
-
continue;
|
|
272
|
-
subSize = subList.length;
|
|
273
|
-
for (j = 0; j < subSize; j++)
|
|
274
|
-
result[i + j * this._concurrent] = subList[j];
|
|
275
|
-
}
|
|
276
|
-
this.splice(0, this.length);
|
|
277
|
-
this.push.apply(this, result);
|
|
278
|
-
this._operation = [];
|
|
279
|
-
return [2 /*return*/, this];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
return TStream;
|
|
285
|
-
}(Array));
|
|
286
|
-
__1.UtilCodec.decodeHtmlEntities('112233'); //?
|