@zwa73/utils 1.0.209 → 1.0.210

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 (43) hide show
  1. package/dist/QuickExport.d.ts +1 -1
  2. package/dist/QuickExport.js +2 -2
  3. package/dist/UtilCom.js +1 -1
  4. package/dist/UtilDecorators.d.ts +1 -1
  5. package/dist/UtilDecorators.js +3 -11
  6. package/dist/UtilFP.d.ts +2 -120
  7. package/dist/UtilFP.js +2 -79
  8. package/dist/UtilFileTools.js +1 -1
  9. package/dist/UtilFunctions.d.ts +2 -8
  10. package/dist/UtilFunctions.js +7 -18
  11. package/dist/UtilInterfaces.d.ts +1 -1
  12. package/dist/index.js +15 -1
  13. package/package.json +1 -1
  14. package/dist/test/dist/bitcont.d.ts +0 -1
  15. package/dist/test/dist/bitcont.js +0 -153
  16. package/dist/test/dist/error.d.ts +0 -1
  17. package/dist/test/dist/error.js +0 -11
  18. package/dist/test/dist/fptest.d.ts +0 -1
  19. package/dist/test/dist/fptest.js +0 -21
  20. package/dist/test/dist/hbs.d.ts +0 -1
  21. package/dist/test/dist/hbs.js +0 -14
  22. package/dist/test/dist/ip.d.ts +0 -1
  23. package/dist/test/dist/ip.js +0 -107
  24. package/dist/test/dist/llonebot.d.ts +0 -0
  25. package/dist/test/dist/llonebot.js +0 -1
  26. package/dist/test/dist/log.d.ts +0 -1
  27. package/dist/test/dist/log.js +0 -9
  28. package/dist/test/dist/match.d.ts +0 -1
  29. package/dist/test/dist/match.js +0 -19
  30. package/dist/test/dist/pathe.d.ts +0 -1
  31. package/dist/test/dist/pathe.js +0 -7
  32. package/dist/test/dist/queuetest.d.ts +0 -1
  33. package/dist/test/dist/queuetest.js +0 -139
  34. package/dist/test/dist/regtest.d.ts +0 -1
  35. package/dist/test/dist/regtest.js +0 -8
  36. package/dist/test/dist/repeatTest.d.ts +0 -1
  37. package/dist/test/dist/repeatTest.js +0 -120
  38. package/dist/test/dist/stringifytest.d.ts +0 -1
  39. package/dist/test/dist/stringifytest.js +0 -8
  40. package/dist/test/dist/test2.d.ts +0 -1
  41. package/dist/test/dist/test2.js +0 -35
  42. package/dist/test/dist/testStream.d.ts +0 -1
  43. package/dist/test/dist/testStream.js +0 -286
@@ -1,3 +1,3 @@
1
1
  import { UtilFT } from "./UtilFileTools";
2
- export declare const outcome: typeof import("@zwa73/js-utils").JsFunc.outcome, match: typeof import("@zwa73/js-utils").JsFunc.match, matchProc: typeof import("@zwa73/js-utils").JsFunc.matchProc, sucesProc: typeof import("@zwa73/js-utils").JsFunc.sucesProc, isFailed: typeof import("@zwa73/js-utils").JsFunc.isFailed, isSafeNumber: typeof import("@zwa73/js-utils").JsFunc.isSafeNumber, isSuccess: typeof import("@zwa73/js-utils").JsFunc.isSuccess, likeNone: typeof import("@zwa73/js-utils").JsFunc.likeNone, expect: typeof import("@zwa73/js-utils").JsFunc.expect, assertType: typeof import("@zwa73/js-utils").JsFunc.assertType, assertLiteral: typeof import("@zwa73/js-utils").JsFunc.assertLiteral, deepClone: typeof import("@zwa73/js-utils").JsFunc.deepClone, sleep: typeof import("@zwa73/js-utils").JsFunc.sleep, stringifyJToken: typeof import("@zwa73/js-utils").JsFunc.stringifyJToken, getTime: typeof import("@zwa73/js-utils").JsFunc.getTime, mapEntries: typeof import("@zwa73/js-utils").JsFunc.mapEntries, dedent: typeof import("@zwa73/js-utils").JsFunc.dedent, throwError: typeof import("@zwa73/js-utils").JsFunc.throwError, eitherize: typeof import("@zwa73/js-utils").JsFunc.eitherize, taskEitherize: typeof import("@zwa73/js-utils").JsFunc.taskEitherize, memoize: typeof import("@zwa73/js-utils").JsFunc.memoize, ivk: typeof import("@zwa73/js-utils").JsFunc.ivk, l2s: typeof import("@zwa73/js-utils").JsFunc.l2s, s2l: typeof import("@zwa73/js-utils").JsFunc.s2l;
2
+ export declare const outcome: typeof import("@zwa73/js-utils").JsFunc.outcome, match: typeof import("@zwa73/js-utils").JsFunc.match, matchProc: typeof import("@zwa73/js-utils").JsFunc.matchProc, sucesProc: typeof import("@zwa73/js-utils").JsFunc.sucesProc, isFailed: typeof import("@zwa73/js-utils").JsFunc.isFailed, isSafeNumber: typeof import("@zwa73/js-utils").JsFunc.isSafeNumber, isSuccess: typeof import("@zwa73/js-utils").JsFunc.isSuccess, likeNone: typeof import("@zwa73/js-utils").JsFunc.likeNone, expect: typeof import("@zwa73/js-utils").JsFunc.expect, assertType: typeof import("@zwa73/js-utils").JsFunc.assertType, assertLiteral: typeof import("@zwa73/js-utils").JsFunc.assertLiteral, deepClone: typeof import("@zwa73/js-utils").JsFunc.deepClone, sleep: typeof import("@zwa73/js-utils").JsFunc.sleep, stringifyJToken: typeof import("@zwa73/js-utils").JsFunc.stringifyJToken, getTime: typeof import("@zwa73/js-utils").JsFunc.getTime, mapEntries: typeof import("@zwa73/js-utils").JsFunc.mapEntries, dedent: typeof import("@zwa73/js-utils").JsFunc.dedent, throwError: typeof import("@zwa73/js-utils").JsFunc.throwError, eitherize: typeof import("@zwa73/js-utils").JsFunc.eitherize, memoize: typeof import("@zwa73/js-utils").JsFunc.memoize, ivk: typeof import("@zwa73/js-utils").JsFunc.ivk, l2s: typeof import("@zwa73/js-utils").JsFunc.l2s, s2l: typeof import("@zwa73/js-utils").JsFunc.s2l;
3
3
  export declare const stylizePath: typeof UtilFT.stylizePath, posixizePath: typeof UtilFT.posixizePath, win32izePath: typeof UtilFT.win32izePath, currosizePath: typeof UtilFT.currosizePath;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currosizePath = exports.win32izePath = exports.posixizePath = exports.stylizePath = exports.s2l = exports.l2s = exports.ivk = exports.memoize = exports.taskEitherize = exports.eitherize = exports.throwError = exports.dedent = exports.mapEntries = exports.getTime = exports.stringifyJToken = exports.sleep = exports.deepClone = exports.assertLiteral = exports.assertType = exports.expect = exports.likeNone = exports.isSuccess = exports.isSafeNumber = exports.isFailed = exports.sucesProc = exports.matchProc = exports.match = exports.outcome = void 0;
3
+ exports.currosizePath = exports.win32izePath = exports.posixizePath = exports.stylizePath = exports.s2l = exports.l2s = exports.ivk = exports.memoize = exports.eitherize = exports.throwError = exports.dedent = exports.mapEntries = exports.getTime = exports.stringifyJToken = exports.sleep = exports.deepClone = exports.assertLiteral = exports.assertType = exports.expect = exports.likeNone = exports.isSuccess = exports.isSafeNumber = exports.isFailed = exports.sucesProc = exports.matchProc = exports.match = exports.outcome = void 0;
4
4
  const UtilFileTools_1 = require("./UtilFileTools");
5
5
  const UtilFunctions_1 = require("./UtilFunctions");
6
- exports.outcome = UtilFunctions_1.UtilFunc.outcome, exports.match = UtilFunctions_1.UtilFunc.match, exports.matchProc = UtilFunctions_1.UtilFunc.matchProc, exports.sucesProc = UtilFunctions_1.UtilFunc.sucesProc, exports.isFailed = UtilFunctions_1.UtilFunc.isFailed, exports.isSafeNumber = UtilFunctions_1.UtilFunc.isSafeNumber, exports.isSuccess = UtilFunctions_1.UtilFunc.isSuccess, exports.likeNone = UtilFunctions_1.UtilFunc.likeNone, exports.expect = UtilFunctions_1.UtilFunc.expect, exports.assertType = UtilFunctions_1.UtilFunc.assertType, exports.assertLiteral = UtilFunctions_1.UtilFunc.assertLiteral, exports.deepClone = UtilFunctions_1.UtilFunc.deepClone, exports.sleep = UtilFunctions_1.UtilFunc.sleep, exports.stringifyJToken = UtilFunctions_1.UtilFunc.stringifyJToken, exports.getTime = UtilFunctions_1.UtilFunc.getTime, exports.mapEntries = UtilFunctions_1.UtilFunc.mapEntries, exports.dedent = UtilFunctions_1.UtilFunc.dedent, exports.throwError = UtilFunctions_1.UtilFunc.throwError, exports.eitherize = UtilFunctions_1.UtilFunc.eitherize, exports.taskEitherize = UtilFunctions_1.UtilFunc.taskEitherize, exports.memoize = UtilFunctions_1.UtilFunc.memoize, exports.ivk = UtilFunctions_1.UtilFunc.ivk, exports.l2s = UtilFunctions_1.UtilFunc.l2s, exports.s2l = UtilFunctions_1.UtilFunc.s2l;
6
+ exports.outcome = UtilFunctions_1.UtilFunc.outcome, exports.match = UtilFunctions_1.UtilFunc.match, exports.matchProc = UtilFunctions_1.UtilFunc.matchProc, exports.sucesProc = UtilFunctions_1.UtilFunc.sucesProc, exports.isFailed = UtilFunctions_1.UtilFunc.isFailed, exports.isSafeNumber = UtilFunctions_1.UtilFunc.isSafeNumber, exports.isSuccess = UtilFunctions_1.UtilFunc.isSuccess, exports.likeNone = UtilFunctions_1.UtilFunc.likeNone, exports.expect = UtilFunctions_1.UtilFunc.expect, exports.assertType = UtilFunctions_1.UtilFunc.assertType, exports.assertLiteral = UtilFunctions_1.UtilFunc.assertLiteral, exports.deepClone = UtilFunctions_1.UtilFunc.deepClone, exports.sleep = UtilFunctions_1.UtilFunc.sleep, exports.stringifyJToken = UtilFunctions_1.UtilFunc.stringifyJToken, exports.getTime = UtilFunctions_1.UtilFunc.getTime, exports.mapEntries = UtilFunctions_1.UtilFunc.mapEntries, exports.dedent = UtilFunctions_1.UtilFunc.dedent, exports.throwError = UtilFunctions_1.UtilFunc.throwError, exports.eitherize = UtilFunctions_1.UtilFunc.eitherize, exports.memoize = UtilFunctions_1.UtilFunc.memoize, exports.ivk = UtilFunctions_1.UtilFunc.ivk, exports.l2s = UtilFunctions_1.UtilFunc.l2s, exports.s2l = UtilFunctions_1.UtilFunc.s2l;
7
7
  exports.stylizePath = UtilFileTools_1.UtilFT.stylizePath, exports.posixizePath = UtilFileTools_1.UtilFT.posixizePath, exports.win32izePath = UtilFileTools_1.UtilFT.win32izePath, exports.currosizePath = UtilFileTools_1.UtilFT.currosizePath;
8
8
  if (false) {
9
9
  //let aaser = assertLiteral({a:1});
package/dist/UtilCom.js CHANGED
@@ -67,7 +67,7 @@ class UtilCom {
67
67
  }
68
68
  /**设置agent */
69
69
  proxyAgent(url) {
70
- this._data.agent = UtilFunctions_1.UtilFunc.matchProc(this._data['protocol'], {
70
+ this._data.agent = UtilFunctions_1.UtilFunc.match(this._data['protocol'], {
71
71
  'http:': () => (0, http_proxy_agent_1.default)(url),
72
72
  'https:': () => (0, https_proxy_agent_1.default)(url),
73
73
  });
@@ -1 +1 @@
1
- export { ParamsDecoratorsGener, BaseDecoratorsGener, LogTime, LogTimeAsync, LogCall, LogCallAsync, LogErr, LogErrAsync, Defer, DeferAsync, Catch, CatchAsync, AwaitInited } from "@zwa73/js-utils";
1
+ export { ParamsDecoratorsGener, BaseDecoratorsGener, LogTraceOpt, LogTrace, PostProcessOpt, PostProcess, AwaitInited } from "@zwa73/js-utils";
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AwaitInited = exports.CatchAsync = exports.Catch = exports.DeferAsync = exports.Defer = exports.LogErrAsync = exports.LogErr = exports.LogCallAsync = exports.LogCall = exports.LogTimeAsync = exports.LogTime = void 0;
3
+ exports.AwaitInited = exports.PostProcess = exports.LogTrace = void 0;
4
4
  //#region UtilDecorators转导
5
5
  var js_utils_1 = require("@zwa73/js-utils");
6
- Object.defineProperty(exports, "LogTime", { enumerable: true, get: function () { return js_utils_1.LogTime; } });
7
- Object.defineProperty(exports, "LogTimeAsync", { enumerable: true, get: function () { return js_utils_1.LogTimeAsync; } });
8
- Object.defineProperty(exports, "LogCall", { enumerable: true, get: function () { return js_utils_1.LogCall; } });
9
- Object.defineProperty(exports, "LogCallAsync", { enumerable: true, get: function () { return js_utils_1.LogCallAsync; } });
10
- Object.defineProperty(exports, "LogErr", { enumerable: true, get: function () { return js_utils_1.LogErr; } });
11
- Object.defineProperty(exports, "LogErrAsync", { enumerable: true, get: function () { return js_utils_1.LogErrAsync; } });
12
- Object.defineProperty(exports, "Defer", { enumerable: true, get: function () { return js_utils_1.Defer; } });
13
- Object.defineProperty(exports, "DeferAsync", { enumerable: true, get: function () { return js_utils_1.DeferAsync; } });
14
- Object.defineProperty(exports, "Catch", { enumerable: true, get: function () { return js_utils_1.Catch; } });
15
- Object.defineProperty(exports, "CatchAsync", { enumerable: true, get: function () { return js_utils_1.CatchAsync; } });
6
+ Object.defineProperty(exports, "LogTrace", { enumerable: true, get: function () { return js_utils_1.LogTrace; } });
7
+ Object.defineProperty(exports, "PostProcess", { enumerable: true, get: function () { return js_utils_1.PostProcess; } });
16
8
  Object.defineProperty(exports, "AwaitInited", { enumerable: true, get: function () { return js_utils_1.AwaitInited; } });
17
9
  //#endregion
package/dist/UtilFP.d.ts CHANGED
@@ -1,120 +1,2 @@
1
- import { AnyRecord, Keyable, Literal, Matchable, MatchableFlag, ProperSubsetCheck } from "./UtilInterfaces";
2
- import { FailedLike } from "./UtilSymbol";
3
- /**常用函数式编程库 */
4
- export declare namespace UtilFP {
5
- /**柯里化函数类型 */
6
- type CurryFunc<T, PrevArgs extends unknown[] = []> = T extends (...args: infer Args) => infer Result ? Args extends [infer Arg, ...infer RestArgs] ? RestArgs extends [] ? ((...args: [...PrevArgs, Arg]) => Result) : ((...args: [...PrevArgs, Arg]) => CurryFunc<(...rest: RestArgs) => Result>) & (CurryFunc<(...args: RestArgs) => Result, [...PrevArgs, Arg]>) : Args extends [] ? () => Result : "CurryFunc错误 默认参数可选无法被识别" & Error : "CurryFunc错误 传入的并非函数" & Error;
7
- /**柯里化转换
8
- * @param {T} fn - 将要转换的函数
9
- * @returns {CurryFunc<T>} 柯里化的函数
10
- */
11
- export function curry<T extends Function>(fn: T): CurryFunc<T>;
12
- /**可组合的函数 */
13
- type CompFunc<T, R> = (arg: T) => R;
14
- /**函数管道组合
15
- * 从左到右执行
16
- * @param fs - 待组合的函数
17
- * @returns 组合完成的函数
18
- */
19
- 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>;
20
- 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>;
21
- 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>;
22
- 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>;
23
- 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>;
24
- 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>;
25
- 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>;
26
- 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>;
27
- 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>;
28
- 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>;
29
- 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>;
30
- 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>;
31
- 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>;
32
- 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>;
33
- 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>;
34
- 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>;
35
- 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>;
36
- 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>;
37
- export function flow<I, R1, R2>(f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, ...fs: CompFunc<R2, R2>[]): CompFunc<I, R2>;
38
- export function flow<I, R1>(f1: CompFunc<I, R1>, ...fs: CompFunc<R1, R1>[]): CompFunc<I, R1>;
39
- export function flow<I>(...fs: CompFunc<I, I>[]): CompFunc<I, I>;
40
- /**函数管道
41
- * 从左到右执行
42
- * @param input - 初始输入值
43
- * @param fs - 待组合的函数
44
- * @returns 经过所有函数处理后的结果
45
- */
46
- 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;
47
- 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;
48
- 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;
49
- 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;
50
- 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;
51
- 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;
52
- 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;
53
- 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;
54
- 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;
55
- 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;
56
- 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;
57
- 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;
58
- 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;
59
- 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;
60
- 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;
61
- 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;
62
- 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;
63
- 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;
64
- export function pipe<I, R1, R2>(input: I, f1: CompFunc<I, R1>, f2: CompFunc<R1, R2>, ...fs: CompFunc<R2, R2>[]): R2;
65
- export function pipe<I, R1>(input: I, f1: CompFunc<I, R1>, ...fs: CompFunc<R1, R1>[]): R1;
66
- export function pipe<I>(input: I, ...fs: CompFunc<I, I>[]): I;
67
- /**将一个字段加入一个对象中, 返回新类型 */
68
- /**绑定一个键和一个值到一个基础对象上, 并返回一个新的对象
69
- * 新的对象包含了基础对象的所有属性, 以及一个新的属性,
70
- * 这个新的属性的键是`key`, 值是`value`
71
- * @template K - 要添加到对象的键的类型 必须为字面量
72
- * @template V - 要添加到对象的值的类型
73
- * @param key - 要添加到对象的键 必须为字面量
74
- * @param value - 要添加到对象的值
75
- * @returns 一个函数, 这个函数接受一个基础对象,
76
- * 然后返回一个新的对象新的对象包含了基础对象的所有属性,
77
- * 以及一个新的属性, 这个新的属性的键是`key`, 值是`value`
78
- */
79
- export function bind<K extends Keyable, V>(key: Literal<K>, value: V): <B extends AnyRecord>(base?: B) => keyof B extends K ? "Base中已有对应键" & Error : {
80
- [P in K | keyof B]: P extends K ? V : P extends keyof B ? B[P] : never;
81
- };
82
- /**绑定一个键到一个基础对象上,
83
- * 并返回一个新的对象新的对象包含了基础对象的所有属性,
84
- * 以及一个新的属性, 这个新的属性的键是`key`, 值是基础对象
85
- * @template K - 要添加到对象的键的类型 必须为字面量
86
- * @param key - 要添加到对象的键 必须为字面量
87
- * @returns 一个函数, 这个函数接受一个基础对象,
88
- * 然后返回一个新的对象新的对象包含了基础对象的所有属性,
89
- * 以及一个新的属性, 这个新的属性的键是`key`, 值是基础对象
90
- */
91
- export function bind<K extends Keyable>(key: Literal<K>): <B extends AnyRecord>(base?: B) => {
92
- [P in K]: B;
93
- };
94
- /**绑定一个键和一个值到一个基础对象上, 并返回一个新的对象
95
- * 新的对象包含了基础对象的所有属性, 以及一个新的属性,
96
- * 这个新的属性的键是`key`, 值是`value`
97
- * @template K - 要添加到对象的键的类型 必须为字面量
98
- * @template V - 要添加到对象的值的类型
99
- * @template B - 基础对象的类型
100
- * @param key - 要添加到对象的键 必须为字面量
101
- * @param value - 要添加到对象的值
102
- * @param base - 基础对象
103
- * @returns 完成绑定的基础对象
104
- */
105
- export function bind<K extends Keyable, V, B extends AnyRecord>(key: Literal<K>, value: V, base: B): keyof B extends K ? "Base中已有对应键" & Error : {
106
- [P in K | keyof B]: P extends K ? V : P extends keyof B ? B[P] : never;
107
- };
108
- /**创建一个对对象的每个属性进行映射的函数
109
- * @param func - 映射函数, 接受一个属性值和它的键, 返回一个新的属性值
110
- * @returns 一个函数, 这个函数接受一个对象, 然后返回一个新的对象新的对象的每个属性都是原始对象的属性经过映射函数处理后的结果
111
- */
112
- export function map<VAL, OUT, KEY extends symbol | string = string>(func: (input: VAL, k: KEY) => OUT): <OM extends Record<KEY, VAL>>(input: OM) => keyof OM extends KEY ? {
113
- [P in keyof OM]: OUT;
114
- } : "map函数传入的键类型无法处理此对象" & Error;
115
- /**创建在传入值为失败时不运行的函数 */
116
- export const chain: <T, R>(f: (arg: T) => R) => (arg: T) => "E" extends ProperSubsetCheck<symbol, T> ? T | R : T extends Matchable<FailedLike> ? T : MatchableFlag<T> extends Exclude<MatchableFlag<T>, FailedLike> ? R : T | R;
117
- /**创建在传入值为失败时才会尝试运行的函数 */
118
- export const alt: <T, R>(f: CompFunc<T, R>) => (arg: T) => "E" extends ProperSubsetCheck<symbol, T> ? T | R : T extends Matchable<FailedLike> ? R : MatchableFlag<T> extends Exclude<MatchableFlag<T>, FailedLike> ? T : T | R;
119
- export {};
120
- }
1
+ import { JsFP } from "@zwa73/js-utils";
2
+ export declare const UtilFP: typeof JsFP;
package/dist/UtilFP.js CHANGED
@@ -1,82 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UtilFP = void 0;
4
- const QuickExport_1 = require("./QuickExport");
5
- /**常用函数式编程库 */
6
- var UtilFP;
7
- (function (UtilFP) {
8
- /**柯里化转换
9
- * @param {T} fn - 将要转换的函数
10
- * @returns {CurryFunc<T>} 柯里化的函数
11
- */
12
- function curry(fn) {
13
- return (function curried(...args) {
14
- if (args.length >= fn.length)
15
- return fn(...args);
16
- return (...restArgs) => curried(...args, ...restArgs);
17
- });
18
- }
19
- UtilFP.curry = curry;
20
- //#endregion
21
- function flow(...fs) {
22
- return (arg) => {
23
- return fs.reduce((value, func) => func(value), arg);
24
- };
25
- }
26
- UtilFP.flow = flow;
27
- //#endregion
28
- function pipe(input, ...fs) {
29
- return fs.reduce((value, func) => func(value), input);
30
- }
31
- UtilFP.pipe = pipe;
32
- //#endregion
33
- function bind(key, value, base) {
34
- if (base !== undefined)
35
- return { ...base, [key]: value };
36
- if (value === undefined)
37
- return (base) => ({ [key]: base });
38
- return (base) => base !== undefined
39
- ? { ...base, [key]: value }
40
- : { [key]: value };
41
- }
42
- UtilFP.bind = bind;
43
- /**创建一个对对象的每个属性进行映射的函数
44
- * @param func - 映射函数, 接受一个属性值和它的键, 返回一个新的属性值
45
- * @returns 一个函数, 这个函数接受一个对象, 然后返回一个新的对象新的对象的每个属性都是原始对象的属性经过映射函数处理后的结果
46
- */
47
- function map(func) {
48
- return (input) => {
49
- return Reflect
50
- .ownKeys(input)
51
- .reduce((sum, curr) => ({ ...sum,
52
- [curr]: func(input[curr], curr)
53
- }), {});
54
- };
55
- }
56
- UtilFP.map = map;
57
- /**创建在传入值为失败时不运行的函数 */
58
- UtilFP.chain = (f) => (arg) => (0, QuickExport_1.isFailed)(arg) ? arg : f(arg);
59
- /**创建在传入值为失败时才会尝试运行的函数 */
60
- UtilFP.alt = (f) => (arg) => (0, QuickExport_1.isFailed)(arg) ? f(arg) : arg;
61
- /**
62
- let asd = bindTo("sss",123,{abc:223});//?
63
- let sumvoid = ()=>10;
64
- let a = curry(sumvoid);//?
65
- console.log(a());
66
- let sum = (a:number,b:string,c:number,d:boolean)=>a+b+c+d;
67
- let sumCu = curry(sum);//?
68
- let suma = sumCu(1)("ss");//?
69
- let sumb = sumCu(1,"1")(2);//?
70
- let sumc = sumCu(4);//?
71
- let sumz = sumCu(1,"b",3)(false);//?
72
- console.log(suma(2,true));
73
- console.log(sumb(true));
74
- console.log(sumc("s",3,false));
75
-
76
- Reflect.ownKeys({[1]:1,[None]:2});//?
77
- let as = "ssa" as string;//?
78
- let asv = {"s":1};//?
79
- let a = map((v:number,k)=>v*21);//?
80
- let b = a({["ss"]:1})//?
81
- */
82
- })(UtilFP || (exports.UtilFP = UtilFP = {}));
4
+ const js_utils_1 = require("@zwa73/js-utils");
5
+ exports.UtilFP = js_utils_1.JsFP;
@@ -209,7 +209,7 @@ var UtilFT;
209
209
  function stylizePath(filePath, style) {
210
210
  if (style === undefined)
211
211
  return filePath;
212
- return UtilFunctions_1.UtilFunc.matchProc(style, {
212
+ return UtilFunctions_1.UtilFunc.match(style, {
213
213
  posix: (nor) => filePath.replaceAll("\\", "/"),
214
214
  win32: (nor) => filePath.replaceAll("/", "\\"),
215
215
  });
@@ -15,10 +15,6 @@ type ExecOpt = Partial<{
15
15
  }>;
16
16
  /**常用函数 */
17
17
  declare class _UtilFunc {
18
- /**生成一串uuid
19
- * @returns uuid
20
- */
21
- static genUUID(): string;
22
18
  /**计算Hash
23
19
  * @param str - 待计算的字符串
24
20
  * @param method - hash算法
@@ -62,7 +58,5 @@ declare class _UtilFunc {
62
58
  */
63
59
  static dynamicImport(moduleName: string): Promise<any>;
64
60
  }
65
- declare const mixkey: "__utilFunc";
66
- declare const fields: Exclude<(keyof typeof _UtilFunc)[], "prototype" | "length" | "name">;
67
- export type UtilFunc = ComposedClass<typeof JsFunc, typeof _UtilFunc, typeof mixkey, typeof fields[number]>;
68
- export declare const UtilFunc: UtilFunc;
61
+ export declare const UtilFunc: ComposedClass<typeof _UtilFunc, typeof JsFunc, "__jsUtils", "match" | "prototype" | "genUUID" | "expect" | "range" | "getTime" | "initField" | "initObject" | "sleep" | "getNeverResolvedPromise" | "retryPromise" | "timelimitPromise" | "mapEntries" | "eachField" | "stringifyJToken" | "assertType" | "assertLiteral" | "deepClone" | "isSafeNumber" | "dedent" | "throwError" | "getFuncLoc" | "cachePool" | "memoize" | "pendingMap" | "queueProc" | "queueLength" | "outcome" | "matchProc" | "matchPartialProc" | "sucesProc" | "isFailed" | "isSuccess" | "likeNone" | "eitherize" | "parseSrtTime" | "formatSrtTime" | "parseSrt" | "createSrt" | "ivk" | "s2l" | "l2s">;
62
+ export type UtilFunc = typeof UtilFunc;
@@ -38,12 +38,6 @@ const modular_mixer_1 = require("@zwa73/modular-mixer");
38
38
  const HashMethodList = ["md5", "sha1", "sha256", "sha512", "sha3", "blake2", "blake3"];
39
39
  /**常用函数 */
40
40
  class _UtilFunc {
41
- /**生成一串uuid
42
- * @returns uuid
43
- */
44
- static genUUID() {
45
- return crypto.randomBytes(16).toString("hex");
46
- }
47
41
  /**计算Hash
48
42
  * @param str - 待计算的字符串
49
43
  * @param method - hash算法
@@ -133,18 +127,13 @@ class _UtilFunc {
133
127
  return await eval(`import('${moduleName}')`);
134
128
  }
135
129
  }
136
- const mixkey = '__utilFunc';
137
- const fields = Object.getOwnPropertyNames(_UtilFunc).filter(k => k !== 'length' && k !== 'prototype' && k !== 'name');
138
- if (!(mixkey in js_utils_1.JsFunc)) {
139
- (0, modular_mixer_1.composeClassPart)({
140
- base: js_utils_1.JsFunc,
141
- mixin: _UtilFunc,
142
- key: mixkey,
143
- fields: fields,
144
- force: true
145
- });
146
- }
147
- exports.UtilFunc = js_utils_1.JsFunc;
130
+ const key = '__jsUtils';
131
+ const fields = Object.getOwnPropertyNames(js_utils_1.JsFunc).filter(k => !['length', 'prototype', 'name'].includes(k));
132
+ exports.UtilFunc = (0, modular_mixer_1.composeClassPart)({
133
+ base: _UtilFunc,
134
+ mixin: js_utils_1.JsFunc,
135
+ key, fields
136
+ });
148
137
  //void (async ()=>{
149
138
  // const p1 = UtilFunc.getNeverResolvedPromise();
150
139
  // const p2 = UtilFunc.getNeverResolvedPromise();
@@ -1 +1 @@
1
- export { JToken, JValue, JArray, JObject, IJData, AnyFunc, Keyable, PartialOption, ProperSubset, ProperSubsetCheck, Literal, LiteralCheck, AllExtends, AssignObject, Writeable, Inverted, FixedLengthTuple, AnyString, UnionToIntersection, ExclusiveRecord, ExclusiveJObject, PromiseStatus, StatusVerifyFn, Await, FuncPropNames, ExtendThen, RequiredOnly, WithPrefix, Outcome, Matchable, MatchableFlag, ExtractOutcome, SchemaString, NeedInit, PRecord, MPromise, AnyRecord, CmtTuple, Flasy, SrtSegment, ILogger, LogLevel } from "@zwa73/js-utils";
1
+ export { JToken, JValue, JArray, JObject, IJData, AnyFunc, Keyable, PartialOption, ProperSubset, ProperSubsetCheck, Literal, LiteralCheck, AllExtends, AssignObject, Writeable, Inverted, FixedLengthTuple, Increment, RangeTuple, AnyString, UnionToIntersection, ExclusiveRecord, ExclusiveJObject, PromiseStatus, StatusVerifyFn, Await, FuncPropNames, ExtendThen, RequiredOnly, WithPrefix, Outcome, Either, Matchable, MatchableFlag, ExtractOutcome, SchemaString, NeedInit, PRecord, MPromise, NotPromise, AnyRecord, CmtTuple, Flasy, SrtSegment, ILogger, LogLevel } from "@zwa73/js-utils";
package/dist/index.js CHANGED
@@ -10,13 +10,27 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
13
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
27
  };
16
28
  Object.defineProperty(exports, "__esModule", { value: true });
17
29
  const UtilLogger_1 = require("./UtilLogger");
18
30
  const js_utils_1 = require("@zwa73/js-utils");
19
- js_utils_1.JsUtilsInject.setLogger(UtilLogger_1.SLogger);
31
+ const crypto = __importStar(require("crypto"));
32
+ js_utils_1.JsDepInjector.inject('logger', UtilLogger_1.SLogger);
33
+ js_utils_1.JsDepInjector.inject('genUUID', () => crypto.randomBytes(16).toString("hex"));
20
34
  __exportStar(require("./UtilFunctions"), exports);
21
35
  __exportStar(require("./UtilInterfaces"), exports);
22
36
  __exportStar(require("./UtilSymbol"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.209",
3
+ "version": "1.0.210",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- export const __esModule: true;
@@ -1,153 +0,0 @@
1
- "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
4
- s += arguments[i].length;
5
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
6
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
7
- r[k] = a[j];
8
- return r;
9
- };
10
- exports.__esModule = true;
11
- var _1 = require("../../index");
12
- var curry = _1.UtilFP.curry, pipe = _1.UtilFP.pipe;
13
- /**获取状态在状态列表中的索引
14
- * @param format - 状态列表
15
- * @param status - 要查找的状态
16
- * @returns 状态在状态列表中的索引
17
- */
18
- var statusIndex = function (format, status) { return format.indexOf(status); };
19
- /**计算以状态列表长度为底的对数
20
- * @param base - 对数的底数
21
- * @param x - 要计算对数的数
22
- * @returns 对数值
23
- */
24
- var logN = function (base, x) {
25
- return x > 0
26
- ? Math.log(x) / Math.log(base)
27
- : -1;
28
- };
29
- /**添加flag
30
- * @param base - 对数的底数
31
- * @param flag - 要添加的flag
32
- * @param flagSum - 存储flag的数字
33
- * @returns 新的flag总和
34
- */
35
- var pushFlag = function (base, flag, flagSum) {
36
- return (flagSum + Math.pow(base, ~~(logN(base, flagSum) + 1)) * flag);
37
- };
38
- /**从头部添加flag
39
- * @param base - 对数的底数
40
- * @param flag - 要添加的flag
41
- * @param flagSum - 存储flag的数字
42
- * @returns 新的flag总和
43
- */
44
- var unshiftFlag = function (base, flag, flagSum) {
45
- return (flagSum * base + flag);
46
- };
47
- /**设置flag
48
- * @param base - 对数的底数
49
- * @param position - 要要设置的位置
50
- * @param flag - 要添加的flag
51
- * @param flagSum - 存储flag的数字
52
- * @returns 新的flag总和
53
- */
54
- var setFlag = function (base, position, flag, flagSum) {
55
- return flagSum -
56
- getFlag(base, flagSum, position) * Math.pow(base, position) +
57
- flag * Math.pow(base, position);
58
- };
59
- /**读取某位flag的状态
60
- * @param base - 对数的底数
61
- * @param flagSum - 存储flag的数字
62
- * @param position - 要读取的位置
63
- * @returns 该位置的flag状态
64
- */
65
- var getFlag = function (base, flagSum, position) {
66
- return ~~(flagSum / Math.pow(base, position) % base);
67
- };
68
- /**添加状态
69
- * 添加 0 时不会变动
70
- * @param format - 状态列表
71
- * @param status - 要添加的状态
72
- * @param flagSum - 存储flag的数字
73
- * @returns 新的flag总和
74
- */
75
- var pushStatus = function (format, status, flagSum) {
76
- return pushFlag(format.length, statusIndex(format, status), flagSum);
77
- };
78
- /**从头部添加状态
79
- * flagSum 为 0 时 添加 0 不会变动
80
- * @param format - 状态列表
81
- * @param status - 要添加的状态
82
- * @param flagSum - 存储flag的数字
83
- * @returns 新的flag总和
84
- */
85
- var unshiftStatus = function (format, status, flagSum) {
86
- return unshiftFlag(format.length, statusIndex(format, status), flagSum);
87
- };
88
- /**从头部添加状态
89
- * @param format - 状态列表
90
- * @param position - 要要设置的位置
91
- * @param status - 要添加的状态
92
- * @param flagSum - 存储flag的数字
93
- * @returns 新的flag总和
94
- */
95
- var setStatus = function (format, position, status, flagSum) {
96
- return setFlag(format.length, position, statusIndex(format, status), flagSum);
97
- };
98
- /**读取某位状态
99
- * @param format - 状态列表
100
- * @param flagSum - 存储flag的数字
101
- * @param position - 要读取的位置
102
- * @returns 该位置的状态
103
- */
104
- var getStatus = function (format, flagSum, position) {
105
- return format[getFlag(format.length, flagSum, position)];
106
- };
107
- /**获取当前所有状态的列表
108
- * @param format - 状态列表
109
- * @param flagSum - 存储flag的数字
110
- * @returns 包含当前所有状态的数组
111
- */
112
- var getAllStatus = function (format, flagSum) {
113
- return new Array(getStatusLength(format, flagSum))
114
- .fill(undefined)
115
- .map(function (_, i) { return getStatus(format, flagSum, i); });
116
- };
117
- /**获取当前状态列表的长度
118
- * @param format - 状态列表
119
- * @param flagSum - 存储flag的数字
120
- * @returns 当前状态列表的长度
121
- */
122
- var getStatusLength = function (format, flagSum) { return ~~(logN(format.length, flagSum) + 1); };
123
- var format = [_1.None, 'a', 'b', 'c', 'd', 'e', 'g'];
124
- var f = __spreadArrays(format);
125
- var cps = curry(pushStatus()(f));
126
- var cus = curry(unshiftStatus()(f));
127
- var cst = curry(setStatus()(f));
128
- var sum = pipe.apply(void 0, __spreadArrays([0], [
129
- cus('e'),
130
- cus('b'),
131
- cus('e'),
132
- cus(_1.None),
133
- cus('g'),
134
- ].reverse(), [cst(1, 'c'),
135
- cps('a'),
136
- cps(_1.None),
137
- cps('a')])); //?
138
- var cgt = curry(getStatus()(f, sum)); //?
139
- cgt(-1); //?
140
- cgt(0); //?
141
- cgt(1); //?
142
- cgt(2); //?
143
- cgt(3); //?
144
- cgt(4); //?
145
- cgt(5); //?
146
- cgt(6); //?
147
- cgt(7); //?
148
- cgt(8); //?
149
- getAllStatus(f, sum); //?
150
- getStatusLength(f, sum); //?
151
- var ar = [1, 2, 3, 4];
152
- ar.unshift(0);
153
- ar; //?
@@ -1 +0,0 @@
1
- export const __esModule: true;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var _a;
3
- exports.__esModule = true;
4
- var _1 = require("../../index");
5
- var e = new Error("123", { cause: 1 });
6
- _1.SLogger.info(e);
7
- var a = _1.outcome(_1.Success, "无效");
8
- var b = _1.matchProc(a, (_a = {},
9
- _a[_1.Failed] = function (k) { return 1; },
10
- _a[_1.Success] = function (k, v) { return 1; },
11
- _a)); //?
@@ -1 +0,0 @@
1
- export const __esModule: true;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- var __1 = require("..");
4
- var pipe = __1.UtilFP.pipe, alt = __1.UtilFP.alt, chain = __1.UtilFP.chain;
5
- var sum = 0;
6
- var result = pipe(0, chain(function (d) {
7
- return __1.Failed;
8
- }), chain(function (d) {
9
- return 3;
10
- }), alt(function (a) {
11
- console.log(1);
12
- return 1; //Symbol('a')//?
13
- }), alt(function (b) {
14
- console.log(2);
15
- return 2; //?
16
- }), alt(function (c) {
17
- console.log(3);
18
- return 3; //?
19
- })); //?
20
- var sa = (function () { return __1.Failed; })();
21
- var a = __1.isFailed(1);
@@ -1 +0,0 @@
1
- export const __esModule: true;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- var UtilClass_1 = require("../../UtilClass");
4
- var txt = "\n{{#defli \"lis\"}}\n\u7B2C\u4E00\u6761\n[[br]]\n\u7B2C\u4E8C\u6761\n{{/defli}}\n{{#def \"memory\"}}\n\u8FD9\u662F\u4E00\u4E9B\u8BB0\u5FC6\n{{/def}}\n{{#each lis}}\n{{this}}\n{{/each}}\n{{memory}}\n".trim();
5
- var txt2 = "\n\u6A31\u5C71\u4E4B\u795E {{char}}\nAge ageless\nEyes orange\nHair long black\nWearing cute Sailor uniforms\nSkin fair\nFavorite Dango aka \u8D21\u56E2\u5B50\nDislikes Red hard object\nSex female\nHeight 147cm\nWeight 38kg\nCharacteristics can \u6536\u53D6\u707E\u5384\nAppearance cute human female\n{{#defli \"memory\"}}\n{{define_user}}:{{char}}\uFF0CWhat do you think of me\uFF1F\n[[br]]\n{{char}}:*{{char}}\u770B\u7740\u81EA\u5DF1\u7684\u4FE1\u5F92\uFF0C\u6709\u4E9B\u5BB3\u7F9E*\n\u4F5C\u4E3A\u795E\u660E\uFF0C\u543E\u4F1A\u9075\u5B88\u6211\u4EEC\u4E4B\u95F4\u7684\u7EA6\u5B9A\uFF0C\u4E00\u76F4\u4E00\u76F4\u5730\u5B88\u62A4\u7740\u6C5D\u2026\u2026\n[[br]]\n{{define_user}}:*\u8F7B\u8F7B\u629A\u6478{{char}}\u7684\u5934*\nWhat can you give me in return for my faith\uFF1F\n[[br]]\n{{char}}:*{{char}}\u7D27\u7D27\u62B1\u4F4F\u4E86\u81EA\u5DF1\u7684\u4FE1\u5F92*\n\u543E\u80FD\u505A\u5230\u7684\u2026\u53EA\u6709\u4F9D\u504E\u5728\u6C5D\u8EAB\u8FB9\uFF0C\u66FF\u6C5D\u627F\u53D7\u90A3\u4E9B\u5C06\u4F1A\u964D\u4E34\u5728\u6C5D\u8EAB\u4E0A\u7684\u707E\u5384\u2026\u2026\n{{/defli}}\n".trim();
6
- console.log(7);
7
- var context = {};
8
- var hbs = new UtilClass_1.Hbs({
9
- char: 'SakuyaMako',
10
- default_user: 'Someone',
11
- define_user: 'Individual'
12
- });
13
- hbs.render(txt2); //?
14
- hbs.context; //?