@zwa73/utils 1.0.210 → 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.
@@ -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, 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.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.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;
@@ -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[]>;
@@ -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
  }
@@ -58,5 +58,5 @@ declare class _UtilFunc {
58
58
  */
59
59
  static dynamicImport(moduleName: string): Promise<any>;
60
60
  }
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">;
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
62
  export type UtilFunc = typeof UtilFunc;
@@ -1 +1 @@
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";
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.210",
3
+ "version": "1.0.211",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {