@zwa73/utils 1.0.113 → 1.0.115

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/UtilFP.d.ts CHANGED
@@ -25,6 +25,17 @@ export declare namespace UtilFP {
25
25
  export function flow<I, R1, R2, R3, R4, R5, R6, R7>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, ...fs: CompFunc<R7, R7>[]): CompFunc<I, R7>;
26
26
  export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, ...fs: CompFunc<R8, R8>[]): CompFunc<I, R8>;
27
27
  export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, ...fs: CompFunc<R9, R9>[]): CompFunc<I, R9>;
28
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, ...fs: CompFunc<R10, R10>[]): CompFunc<I, R10>;
29
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, ...fs: CompFunc<R11, R11>[]): CompFunc<I, R11>;
30
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, ...fs: CompFunc<R12, R12>[]): CompFunc<I, R12>;
31
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, ...fs: CompFunc<R13, R13>[]): CompFunc<I, R13>;
32
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, ...fs: CompFunc<R14, R14>[]): CompFunc<I, R14>;
33
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, ...fs: CompFunc<R15, R15>[]): CompFunc<I, R15>;
34
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, ...fs: CompFunc<R16, R16>[]): CompFunc<I, R16>;
35
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, ...fs: CompFunc<R17, R17>[]): CompFunc<I, R17>;
36
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, ...fs: CompFunc<R18, R18>[]): CompFunc<I, R18>;
37
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, ...fs: CompFunc<R19, R19>[]): CompFunc<I, R19>;
38
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, f20: CompFunc<R19, R20>, ...fs: CompFunc<R20, R20>[]): CompFunc<I, R20>;
28
39
  /**函数管道
29
40
  * 从左到右执行
30
41
  * @param input - 初始输入值
@@ -41,6 +52,17 @@ export declare namespace UtilFP {
41
52
  export function pipe<I, R1, R2, R3, R4, R5, R6, R7>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, ...fs: CompFunc<R7, R7>[]): R7;
42
53
  export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, ...fs: CompFunc<R8, R8>[]): R8;
43
54
  export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, ...fs: CompFunc<R9, R9>[]): R9;
55
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, ...fs: CompFunc<R10, R10>[]): R10;
56
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, ...fs: CompFunc<R11, R11>[]): R11;
57
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, ...fs: CompFunc<R12, R12>[]): R12;
58
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, ...fs: CompFunc<R13, R13>[]): R13;
59
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, ...fs: CompFunc<R14, R14>[]): R14;
60
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, ...fs: CompFunc<R15, R15>[]): R15;
61
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, ...fs: CompFunc<R16, R16>[]): R16;
62
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, ...fs: CompFunc<R17, R17>[]): R17;
63
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, ...fs: CompFunc<R18, R18>[]): R18;
64
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, ...fs: CompFunc<R19, R19>[]): R19;
65
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, f20: CompFunc<R19, R20>, ...fs: CompFunc<R20, R20>[]): R20;
44
66
  /**将一个字段加入一个对象中, 返回新类型 */
45
67
  /**绑定一个键和一个值到一个基础对象上, 并返回一个新的对象
46
68
  * 新的对象包含了基础对象的所有属性, 以及一个新的属性,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dev_utils_1 = require("@zwa73/dev-utils");
4
+ const N = 20;
5
+ const R = (n) => n === 0 ? `I` : `R${n}`;
6
+ const prefix = (str, prefix) => str.length > 0 ? `${prefix}${str}` : str;
7
+ const suffix = (str, suffix) => str.length > 0 ? `${str}${suffix}` : str;
8
+ (0, dev_utils_1.$macro)("flow重载", (() => {
9
+ let result = ``;
10
+ for (let i = 0; i <= N; i++) {
11
+ const template = Array.from({ length: i + 1 }, (_, k) => R(k)).join(', ');
12
+ const args = suffix(Array.from({ length: i }, (_, k) => `f${k + 1}: CompFunc<${R(k)}, ${R(k + 1)}>`).join(', '), ", ");
13
+ result += `export function flow<${template}>(${args}...fs: CompFunc<${R(i)}, ${R(i)}>[]): CompFunc<I, ${R(i)}>;\n`;
14
+ }
15
+ return result.trim();
16
+ })());
17
+ (0, dev_utils_1.$macro)("pipe重载", (() => {
18
+ let result = ``;
19
+ for (let i = 0; i <= N; i++) {
20
+ const template = Array.from({ length: i + 1 }, (_, k) => R(k)).join(', ');
21
+ const args = suffix(Array.from({ length: i }, (_, k) => `f${k + 1}: CompFunc<${R(k)}, ${R(k + 1)}>`).join(', '), ", ");
22
+ result += `export function pipe<${template}>(input: I, ${args}...fs: CompFunc<${R(i)}, ${R(i)}>[]): ${R(i)};\n`;
23
+ }
24
+ return result.trim();
25
+ })());
@@ -41,7 +41,6 @@ var UtilFT;
41
41
  */
42
42
  async function pathExists(filePath) {
43
43
  try {
44
- const stats = await fs.promises.stat(filePath);
45
44
  await fs.promises.access(filePath);
46
45
  return true;
47
46
  }
@@ -212,5 +212,12 @@ export declare class UtilFunc {
212
212
  * @param opt - 额外参数
213
213
  */
214
214
  static throwError(message: string, lvl?: LogLevel, opt?: {}): never;
215
+ /**获取函数调用位置 getFunctionLocation
216
+ * @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
217
+ */
218
+ static getFuncLoc(stack?: number): {
219
+ filePath: string;
220
+ lineNumber: `${number}:${number}`;
221
+ } | undefined;
215
222
  }
216
223
  export {};
@@ -572,6 +572,21 @@ class UtilFunc {
572
572
  }
573
573
  throw e;
574
574
  }
575
+ /**获取函数调用位置 getFunctionLocation
576
+ * @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
577
+ */
578
+ static getFuncLoc(stack = 1) {
579
+ const stackLines = new Error().stack.split('\n');
580
+ const regex = /([a-zA-Z]+?:.+?):(\d+?:\d+)/;
581
+ //console.log(stackLines)
582
+ const match = regex.exec(stackLines[stack + 1]);
583
+ if (match) {
584
+ const filePath = match[1];
585
+ const lineNumber = match[2];
586
+ return { filePath, lineNumber };
587
+ }
588
+ return undefined;
589
+ }
575
590
  }
576
591
  exports.UtilFunc = UtilFunc;
577
592
  __decorate([
@@ -100,7 +100,12 @@ class SLogger {
100
100
  messageList[0] = colorizer.colorize(info.level, messageList[0]);
101
101
  for (let i = 1; i < messageList.length; i++)
102
102
  messageList[i] = colorizer.colorize(info.level, messageList[i]);
103
- return `[${info.timestamp}] [${colorizedLevel}]: ${messageList.join("\n")}`;
103
+ let formattedMessage = messageList.join("\n");
104
+ const prefix = `[${info.timestamp}] [${colorizedLevel}]: `;
105
+ if (formattedMessage.startsWith(prefix))
106
+ formattedMessage = formattedMessage.slice(prefix.length);
107
+ return `${prefix}${formattedMessage}`;
108
+ //return `[${info.timestamp}] [${colorizedLevel}]: ${messageList.join("\n")}`;
104
109
  }));
105
110
  transports.push(new winston.transports.Console({
106
111
  level: consoleLevel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "postinstall": "start node ./scripts/postinstall.js",
9
9
  "release": "powershell scripts/release",
10
10
  "compile": "powershell scripts/compile",
11
- "watch": "powershell scripts/watch"
11
+ "watch": "powershell scripts/watch",
12
+ "expand-macro": "powershell scripts/expand-macro"
12
13
  },
13
14
  "keywords": [
14
15
  "zwa73"
@@ -16,7 +17,6 @@
16
17
  "author": "zwa73",
17
18
  "license": "ISC",
18
19
  "dependencies": {
19
- "@types/fluent-ffmpeg": "^2.1.21",
20
20
  "esm": "^3.2.25",
21
21
  "esm-resolve": "^1.0.8",
22
22
  "fluent-ffmpeg": "^2.1.2",
@@ -30,9 +30,10 @@
30
30
  "winston-daily-rotate-file": "^4.7.1"
31
31
  },
32
32
  "devDependencies": {
33
+ "@types/fluent-ffmpeg": "^2.1.21",
33
34
  "@types/jest": "^29.5.12",
34
35
  "@types/node": "^18.16.3",
35
- "@zwa73/dev-utils": "^1.0.22",
36
+ "@zwa73/dev-utils": "^1.0.33",
36
37
  "jest": "^29.7.0",
37
38
  "ts-jest": "^29.1.2",
38
39
  "tsc-alias": "^1.8.8",
@@ -1,4 +1,5 @@
1
- Write-Output 开始删除原dist
1
+ npm run expand-macro
2
+ Write-Output 开始删除原dist
2
3
  Remove-Item -Recurse -Force dist
3
4
  Write-Output 开始编译
4
5
  tsc -p tsconfig.compile.json
@@ -0,0 +1,2 @@
1
+ Write-Output 开始展开宏
2
+ npx zcli Expand-Macro
@@ -1,4 +1,3 @@
1
- Write-Output 开始编译
2
- npm run compile
1
+ npm run compile
3
2
  Write-Output 开始发布
4
3
  npx zcli release
@@ -0,0 +1,29 @@
1
+ import {$macro} from '@zwa73/dev-utils';
2
+
3
+ const N = 20;
4
+ const R = (n:number)=>n===0?`I`:`R${n}`;
5
+ const prefix = (str:string,prefix?:string)=> str.length>0?`${prefix}${str}`:str;
6
+ const suffix = (str:string,suffix?:string)=> str.length>0?`${str}${suffix}`:str;
7
+
8
+ $macro("flow重载",(()=>{
9
+ let result = ``;
10
+ for (let i = 0; i <= N; i++) {
11
+ const template = Array.from({length: i+1}, (_, k) => R(k)).join(', ');
12
+ const args = suffix(Array.from({length: i}, (_, k) =>
13
+ `f${k+1}: CompFunc<${R(k)}, ${R(k+1)}>`
14
+ ).join(', '),", ");
15
+ result += `export function flow<${template}>(${args}...fs: CompFunc<${R(i)}, ${R(i)}>[]): CompFunc<I, ${R(i)}>;\n`;
16
+ }
17
+ return result.trim();
18
+ })());
19
+ $macro("pipe重载",(()=>{
20
+ let result = ``;
21
+ for (let i = 0; i <= N; i++) {
22
+ const template = Array.from({length: i+1}, (_, k) => R(k)).join(', ');
23
+ const args = suffix(Array.from({length: i}, (_, k) =>
24
+ `f${k+1}: CompFunc<${R(k)}, ${R(k+1)}>`
25
+ ).join(', '),", ");
26
+ result += `export function pipe<${template}>(input: I, ${args}...fs: CompFunc<${R(i)}, ${R(i)}>[]): ${R(i)};\n`;
27
+ }
28
+ return result.trim();
29
+ })());
package/src/UtilFP.ts CHANGED
@@ -40,15 +40,26 @@ type CompFunc<T, R> = (arg: T) => R;
40
40
  */
41
41
  //#region flow重载
42
42
  export function flow<I>(...fs: CompFunc<I, I>[]): CompFunc<I, I>;
43
- export function flow<I, R1>(f1: CompFunc<I, R1>,...fs: CompFunc<R1, R1>[]): CompFunc<I, R1>;
44
- export function flow<I, R1, R2>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>,...fs: CompFunc<R2, R2>[]): CompFunc<I, R2>;
45
- export function flow<I, R1, R2, R3>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>,...fs: CompFunc<R3, R3>[]): CompFunc<I, R3>;
46
- export function flow<I, R1, R2, R3, R4>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>,...fs: CompFunc<R4, R4>[]): CompFunc<I, R4>;
47
- export function flow<I, R1, R2, R3, R4, R5>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>,...fs: CompFunc<R5, R5>[]): CompFunc<I, R5>;
48
- export function flow<I, R1, R2, R3, R4, R5, R6>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>,...fs: CompFunc<R6, R6>[]): CompFunc<I, R6>;
49
- export function flow<I, R1, R2, R3, R4, R5, R6, R7>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>,...fs: CompFunc<R7, R7>[]): CompFunc<I, R7>;
50
- export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>,...fs: CompFunc<R8, R8>[]): CompFunc<I, R8>;
51
- export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>,...fs: CompFunc<R9, R9>[]): CompFunc<I, R9>;
43
+ export function flow<I, R1>(f1: CompFunc<I, R1>, ...fs: CompFunc<R1, R1>[]): CompFunc<I, R1>;
44
+ export function flow<I, R1, R2>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, ...fs: CompFunc<R2, R2>[]): CompFunc<I, R2>;
45
+ export function flow<I, R1, R2, R3>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, ...fs: CompFunc<R3, R3>[]): CompFunc<I, R3>;
46
+ export function flow<I, R1, R2, R3, R4>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, ...fs: CompFunc<R4, R4>[]): CompFunc<I, R4>;
47
+ export function flow<I, R1, R2, R3, R4, R5>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, ...fs: CompFunc<R5, R5>[]): CompFunc<I, R5>;
48
+ export function flow<I, R1, R2, R3, R4, R5, R6>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, ...fs: CompFunc<R6, R6>[]): CompFunc<I, R6>;
49
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, ...fs: CompFunc<R7, R7>[]): CompFunc<I, R7>;
50
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, ...fs: CompFunc<R8, R8>[]): CompFunc<I, R8>;
51
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, ...fs: CompFunc<R9, R9>[]): CompFunc<I, R9>;
52
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, ...fs: CompFunc<R10, R10>[]): CompFunc<I, R10>;
53
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, ...fs: CompFunc<R11, R11>[]): CompFunc<I, R11>;
54
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, ...fs: CompFunc<R12, R12>[]): CompFunc<I, R12>;
55
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, ...fs: CompFunc<R13, R13>[]): CompFunc<I, R13>;
56
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, ...fs: CompFunc<R14, R14>[]): CompFunc<I, R14>;
57
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, ...fs: CompFunc<R15, R15>[]): CompFunc<I, R15>;
58
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, ...fs: CompFunc<R16, R16>[]): CompFunc<I, R16>;
59
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, ...fs: CompFunc<R17, R17>[]): CompFunc<I, R17>;
60
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, ...fs: CompFunc<R18, R18>[]): CompFunc<I, R18>;
61
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, ...fs: CompFunc<R19, R19>[]): CompFunc<I, R19>;
62
+ export function flow<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, f20: CompFunc<R19, R20>, ...fs: CompFunc<R20, R20>[]): CompFunc<I, R20>;
52
63
  //#endregion
53
64
  export function flow<T>(...fs: ((arg: T) => T)[]): (arg: T) => T {
54
65
  return (arg: T): T => {
@@ -64,15 +75,26 @@ export function flow<T>(...fs: ((arg: T) => T)[]): (arg: T) => T {
64
75
  */
65
76
  //#region pipe重载
66
77
  export function pipe<I>(input: I, ...fs: CompFunc<I, I>[]): I;
67
- export function pipe<I, R1>(input: I, f1: CompFunc<I, R1>,...fs: CompFunc<R1, R1>[]): R1;
68
- export function pipe<I, R1, R2>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>,...fs: CompFunc<R2, R2>[]): R2;
69
- export function pipe<I, R1, R2, R3>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>,...fs: CompFunc<R3, R3>[]): R3;
70
- export function pipe<I, R1, R2, R3, R4>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>,...fs: CompFunc<R4, R4>[]): R4;
71
- export function pipe<I, R1, R2, R3, R4, R5>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>,...fs: CompFunc<R5, R5>[]): R5;
72
- export function pipe<I, R1, R2, R3, R4, R5, R6>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>,...fs: CompFunc<R6, R6>[]): R6;
73
- export function pipe<I, R1, R2, R3, R4, R5, R6, R7>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>,...fs: CompFunc<R7, R7>[]): R7;
74
- export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>,...fs: CompFunc<R8, R8>[]): R8;
75
- export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>,...fs: CompFunc<R9, R9>[]): R9;
78
+ export function pipe<I, R1>(input: I, f1: CompFunc<I, R1>, ...fs: CompFunc<R1, R1>[]): R1;
79
+ export function pipe<I, R1, R2>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, ...fs: CompFunc<R2, R2>[]): R2;
80
+ export function pipe<I, R1, R2, R3>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, ...fs: CompFunc<R3, R3>[]): R3;
81
+ export function pipe<I, R1, R2, R3, R4>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, ...fs: CompFunc<R4, R4>[]): R4;
82
+ export function pipe<I, R1, R2, R3, R4, R5>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, ...fs: CompFunc<R5, R5>[]): R5;
83
+ export function pipe<I, R1, R2, R3, R4, R5, R6>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, ...fs: CompFunc<R6, R6>[]): R6;
84
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, ...fs: CompFunc<R7, R7>[]): R7;
85
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, ...fs: CompFunc<R8, R8>[]): R8;
86
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, ...fs: CompFunc<R9, R9>[]): R9;
87
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, ...fs: CompFunc<R10, R10>[]): R10;
88
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, ...fs: CompFunc<R11, R11>[]): R11;
89
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, ...fs: CompFunc<R12, R12>[]): R12;
90
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, ...fs: CompFunc<R13, R13>[]): R13;
91
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, ...fs: CompFunc<R14, R14>[]): R14;
92
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, ...fs: CompFunc<R15, R15>[]): R15;
93
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, ...fs: CompFunc<R16, R16>[]): R16;
94
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, ...fs: CompFunc<R17, R17>[]): R17;
95
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, ...fs: CompFunc<R18, R18>[]): R18;
96
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, ...fs: CompFunc<R19, R19>[]): R19;
97
+ export function pipe<I, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, f3: CompFunc<R2, R3>, f4: CompFunc<R3, R4>, f5: CompFunc<R4, R5>, f6: CompFunc<R5, R6>, f7: CompFunc<R6, R7>, f8: CompFunc<R7, R8>, f9: CompFunc<R8, R9>, f10: CompFunc<R9, R10>, f11: CompFunc<R10, R11>, f12: CompFunc<R11, R12>, f13: CompFunc<R12, R13>, f14: CompFunc<R13, R14>, f15: CompFunc<R14, R15>, f16: CompFunc<R15, R16>, f17: CompFunc<R16, R17>, f18: CompFunc<R17, R18>, f19: CompFunc<R18, R19>, f20: CompFunc<R19, R20>, ...fs: CompFunc<R20, R20>[]): R20;
76
98
  //#endregion
77
99
  export function pipe<T>(input: T, ...fs: ((arg: T) => T)[]): T {
78
100
  return fs.reduce((value, func) => func(value), input);
@@ -48,7 +48,6 @@ export namespace UtilFT{
48
48
  */
49
49
  export async function pathExists(filePath: string):Promise<boolean>{
50
50
  try {
51
- const stats = await fs.promises.stat(filePath);
52
51
  await fs.promises.access(filePath);
53
52
  return true;
54
53
  } catch (e) {
@@ -649,4 +649,20 @@ static throwError(message:string,lvl?:LogLevel,opt?:{}):never{
649
649
  throw e;
650
650
  }
651
651
 
652
+ /**获取函数调用位置 getFunctionLocation
653
+ * @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
654
+ */
655
+ static getFuncLoc(stack=1) {
656
+ const stackLines = new Error().stack!.split('\n');
657
+ const regex = /([a-zA-Z]+?:.+?):(\d+?:\d+)/;
658
+ //console.log(stackLines)
659
+ const match = regex.exec(stackLines[stack+1]);
660
+ if(match){
661
+ const filePath = match[1];
662
+ const lineNumber = match[2] as `${number}:${number}`;
663
+ return {filePath,lineNumber}
664
+ }
665
+ return undefined;
666
+ }
667
+
652
668
  }
package/src/UtilLogger.ts CHANGED
@@ -91,7 +91,12 @@ export class SLogger{
91
91
  messageList[0]=colorizer.colorize(info.level, messageList[0])
92
92
  for(let i=1;i<messageList.length;i++)
93
93
  messageList[i]=colorizer.colorize(info.level, messageList[i]);
94
- return `[${info.timestamp}] [${colorizedLevel}]: ${messageList.join("\n")}`;
94
+ let formattedMessage = messageList.join("\n");
95
+ const prefix = `[${info.timestamp}] [${colorizedLevel}]: `;
96
+ if (formattedMessage.startsWith(prefix))
97
+ formattedMessage = formattedMessage.slice(prefix.length);
98
+ return `${prefix}${formattedMessage}`;
99
+ //return `[${info.timestamp}] [${colorizedLevel}]: ${messageList.join("\n")}`;
95
100
  }),
96
101
  );
97
102
  transports.push(new winston.transports.Console({