@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.
Files changed (44) hide show
  1. package/dist/QuickExport.d.ts +2 -1
  2. package/dist/QuickExport.js +4 -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.d.ts +4 -2
  9. package/dist/UtilFileTools.js +7 -7
  10. package/dist/UtilFunctions.d.ts +2 -8
  11. package/dist/UtilFunctions.js +7 -18
  12. package/dist/UtilInterfaces.d.ts +1 -1
  13. package/dist/index.js +15 -1
  14. package/package.json +1 -1
  15. package/dist/test/dist/bitcont.d.ts +0 -1
  16. package/dist/test/dist/bitcont.js +0 -153
  17. package/dist/test/dist/error.d.ts +0 -1
  18. package/dist/test/dist/error.js +0 -11
  19. package/dist/test/dist/fptest.d.ts +0 -1
  20. package/dist/test/dist/fptest.js +0 -21
  21. package/dist/test/dist/hbs.d.ts +0 -1
  22. package/dist/test/dist/hbs.js +0 -14
  23. package/dist/test/dist/ip.d.ts +0 -1
  24. package/dist/test/dist/ip.js +0 -107
  25. package/dist/test/dist/llonebot.d.ts +0 -0
  26. package/dist/test/dist/llonebot.js +0 -1
  27. package/dist/test/dist/log.d.ts +0 -1
  28. package/dist/test/dist/log.js +0 -9
  29. package/dist/test/dist/match.d.ts +0 -1
  30. package/dist/test/dist/match.js +0 -19
  31. package/dist/test/dist/pathe.d.ts +0 -1
  32. package/dist/test/dist/pathe.js +0 -7
  33. package/dist/test/dist/queuetest.d.ts +0 -1
  34. package/dist/test/dist/queuetest.js +0 -139
  35. package/dist/test/dist/regtest.d.ts +0 -1
  36. package/dist/test/dist/regtest.js +0 -8
  37. package/dist/test/dist/repeatTest.d.ts +0 -1
  38. package/dist/test/dist/repeatTest.js +0 -120
  39. package/dist/test/dist/stringifytest.d.ts +0 -1
  40. package/dist/test/dist/stringifytest.js +0 -8
  41. package/dist/test/dist/test2.d.ts +0 -1
  42. package/dist/test/dist/test2.js +0 -35
  43. package/dist/test/dist/testStream.d.ts +0 -1
  44. package/dist/test/dist/testStream.js +0 -286
@@ -1,3 +1,4 @@
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, success: typeof import("@zwa73/js-utils").JsFunc.success, failed: typeof import("@zwa73/js-utils").JsFunc.failed, match: typeof import("@zwa73/js-utils").JsFunc.match, isSafeNumber: typeof import("@zwa73/js-utils").JsFunc.isSafeNumber, 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;
4
+ export declare const when: <S extends import("@zwa73/js-utils").Keyable, T, R>(stat: import("@zwa73/js-utils").Literal<S>, f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<S>>) => R) => (arg: T) => ("E" extends import("@zwa73/js-utils").ProperSubsetCheck<symbol, T> ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends S ? R : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<S, import("@zwa73/js-utils").MatchableFlag<T>> ? T : Exclude<T, import("@zwa73/js-utils").Matchable<S>> | R), map: typeof import("@zwa73/js-utils").JsFP.map, flow: typeof import("@zwa73/js-utils").JsFP.flow, pipe: typeof import("@zwa73/js-utils").JsFP.pipe, chain: <T, R>(f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>>) => R) => (arg: T) => ("E" extends import("@zwa73/js-utils").ProperSubsetCheck<symbol, T> ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends typeof import("@zwa73/js-utils").Success ? R : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<typeof import("@zwa73/js-utils").Success, import("@zwa73/js-utils").MatchableFlag<T>> ? T : Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Success>> | R), alt: <T, R>(f: (arg: Extract<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Failed>>) => R) => (arg: T) => ("E" extends import("@zwa73/js-utils").ProperSubsetCheck<symbol, T> ? T | R : import("@zwa73/js-utils").MatchableFlag<T> extends typeof import("@zwa73/js-utils").Failed ? R : import("@zwa73/js-utils").MatchableFlag<T> extends Exclude<typeof import("@zwa73/js-utils").Failed, import("@zwa73/js-utils").MatchableFlag<T>> ? T : Exclude<T, import("@zwa73/js-utils").Matchable<typeof import("@zwa73/js-utils").Failed>> | R);
@@ -1,10 +1,12 @@
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.alt = exports.chain = exports.pipe = exports.flow = exports.map = exports.when = 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.isSafeNumber = exports.match = exports.failed = exports.success = exports.outcome = void 0;
4
4
  const UtilFileTools_1 = require("./UtilFileTools");
5
+ const UtilFP_1 = require("./UtilFP");
5
6
  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;
7
+ exports.outcome = UtilFunctions_1.UtilFunc.outcome, exports.success = UtilFunctions_1.UtilFunc.success, exports.failed = UtilFunctions_1.UtilFunc.failed, exports.match = UtilFunctions_1.UtilFunc.match, exports.isSafeNumber = UtilFunctions_1.UtilFunc.isSafeNumber, 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
8
  exports.stylizePath = UtilFileTools_1.UtilFT.stylizePath, exports.posixizePath = UtilFileTools_1.UtilFT.posixizePath, exports.win32izePath = UtilFileTools_1.UtilFT.win32izePath, exports.currosizePath = UtilFileTools_1.UtilFT.currosizePath;
9
+ exports.when = UtilFP_1.UtilFP.when, exports.map = UtilFP_1.UtilFP.map, exports.flow = UtilFP_1.UtilFP.flow, exports.pipe = UtilFP_1.UtilFP.pipe, exports.chain = UtilFP_1.UtilFP.chain, exports.alt = UtilFP_1.UtilFP.alt;
8
10
  if (false) {
9
11
  //let aaser = assertLiteral({a:1});
10
12
  //let a:"asd"|"dsa" = null as any;
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;
@@ -21,7 +21,9 @@ type FileSearchGlobOpt = Partial<{
21
21
  /**regex搜索选项 */
22
22
  type FileSearchRegexOpt = Partial<{
23
23
  /**搜索子目录 默认 true */
24
- relative: boolean;
24
+ recursive: boolean;
25
+ /**无效项 */
26
+ relative: never;
25
27
  }>;
26
28
  /**json文件加载选项 */
27
29
  type LoadJsonFileOpt<T> = Partial<{
@@ -153,7 +155,7 @@ export declare namespace UtilFT {
153
155
  * @param dir - 起始目录
154
156
  * @param traitRegex - 正则表达式
155
157
  * @param opt - 可选参数
156
- * @param opt.relative - 搜索子目录
158
+ * @param opt.recursive - 搜索子目录
157
159
  * @returns 文件名路径数组
158
160
  */
159
161
  function fileSearchRegex(dir: string, traitRegex: string, opt?: FileSearchRegexOpt): Promise<string[]>;
@@ -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
  });
@@ -263,11 +263,11 @@ var UtilFT;
263
263
  * @param dir - 起始目录
264
264
  * @param traitRegex - 正则表达式
265
265
  * @param opt - 可选参数
266
- * @param opt.relative - 搜索子目录
266
+ * @param opt.recursive - 搜索子目录
267
267
  * @returns 文件名路径数组
268
268
  */
269
269
  async function fileSearchRegex(dir, traitRegex, opt) {
270
- const relative = opt?.relative ?? true;
270
+ const recursive = opt?.recursive ?? true;
271
271
  const outArray = [];
272
272
  const subFiles = await fs.promises.readdir(dir, { withFileTypes: true });
273
273
  //如果使用 g 会导致 RegExp.lastIndex 更改, 将会导致匹配错误
@@ -276,8 +276,8 @@ var UtilFT;
276
276
  const subFilePath = pathe_1.default.join(dir, subFile.name);
277
277
  //判断是否是文件夹,递归调用
278
278
  if (subFile.isDirectory()) {
279
- if (relative)
280
- outArray.push(...await fileSearchRegex(pathe_1.default.join(subFilePath, pathe_1.default.sep), traitRegex));
279
+ if (recursive)
280
+ outArray.push(...await UtilFT.fileSearchRegex(pathe_1.default.join(subFilePath, pathe_1.default.sep), traitRegex));
281
281
  return;
282
282
  }
283
283
  if (regex.test(subFilePath))
@@ -294,7 +294,7 @@ var UtilFT;
294
294
  * @returns 文件名路径数组
295
295
  */
296
296
  function fileSearchRegexSync(dir, traitRegex, opt) {
297
- const relative = opt?.relative ?? true;
297
+ const recursive = opt?.recursive ?? true;
298
298
  const outArray = [];
299
299
  const subFiles = fs.readdirSync(dir, { withFileTypes: true });
300
300
  //如果使用 g 会导致 RegExp.lastIndex 更改, 将会导致匹配错误
@@ -303,7 +303,7 @@ var UtilFT;
303
303
  const subFilePath = pathe_1.default.join(dir, subFile.name);
304
304
  //判断是否是文件夹,递归调用
305
305
  if (subFile.isDirectory()) {
306
- if (relative)
306
+ if (recursive)
307
307
  outArray.push(...fileSearchRegexSync(pathe_1.default.join(subFilePath, pathe_1.default.sep), traitRegex));
308
308
  continue;
309
309
  }
@@ -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" | "failed" | "success" | "prototype" | "genUUID" | "range" | "getTime" | "initField" | "initObject" | "unifyApply" | "sleep" | "getNeverResolvedPromise" | "retryPromise" | "timelimitPromise" | "mapEntries" | "eachField" | "stringifyJToken" | "assertType" | "assertLiteral" | "deepClone" | "isSafeNumber" | "dedent" | "throwError" | "getFuncLoc" | "cachePool" | "memoize" | "asyncize" | "splitToChunk" | "mergeFromChunk" | "pendingMap" | "queueProc" | "queueLength" | "outcome" | "isStatus" | "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, IncludeCheck, UnionCheck, 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, ExtractMatchable, SchemaString, NeedInit, PRecord, MPromise, SPromise, SMPromise, NotPromise, AnyRecord, CmtTuple, Flasy, SrtSegment, ILogger, LogLevel, Asyncize } 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.211",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- export const __esModule: true;