@zwa73/utils 1.0.206 → 1.0.208

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 (47) hide show
  1. package/dist/QuickExport.d.ts +1 -2
  2. package/dist/QuickExport.js +27 -22
  3. package/dist/UtilClass.d.ts +1 -98
  4. package/dist/UtilClass.js +7 -243
  5. package/dist/UtilDecorators.d.ts +1 -32
  6. package/dist/UtilDecorators.js +15 -225
  7. package/dist/UtilFunctions.d.ts +9 -267
  8. package/dist/UtilFunctions.js +38 -687
  9. package/dist/UtilI18n.js +1 -1
  10. package/dist/UtilInterfaces.d.ts +1 -180
  11. package/dist/UtilInterfaces.js +1 -0
  12. package/dist/UtilLogger.d.ts +19 -20
  13. package/dist/UtilLogger.js +1 -1
  14. package/dist/UtilSymbol.d.ts +1 -40
  15. package/dist/UtilSymbol.js +11 -27
  16. package/dist/index.js +3 -0
  17. package/dist/test/dist/bitcont.d.ts +1 -0
  18. package/dist/test/dist/bitcont.js +153 -0
  19. package/dist/test/dist/error.d.ts +1 -0
  20. package/dist/test/dist/error.js +11 -0
  21. package/dist/test/dist/fptest.d.ts +1 -0
  22. package/dist/test/dist/fptest.js +21 -0
  23. package/dist/test/dist/hbs.d.ts +1 -0
  24. package/dist/test/dist/hbs.js +14 -0
  25. package/dist/test/dist/ip.d.ts +1 -0
  26. package/dist/test/dist/ip.js +107 -0
  27. package/dist/test/dist/llonebot.d.ts +0 -0
  28. package/dist/test/dist/llonebot.js +1 -0
  29. package/dist/test/dist/log.d.ts +1 -0
  30. package/dist/test/dist/log.js +9 -0
  31. package/dist/test/dist/match.d.ts +1 -0
  32. package/dist/test/dist/match.js +19 -0
  33. package/dist/test/dist/pathe.d.ts +1 -0
  34. package/dist/test/dist/pathe.js +7 -0
  35. package/dist/test/dist/queuetest.d.ts +1 -0
  36. package/dist/test/dist/queuetest.js +139 -0
  37. package/dist/test/dist/regtest.d.ts +1 -0
  38. package/dist/test/dist/regtest.js +8 -0
  39. package/dist/test/dist/repeatTest.d.ts +1 -0
  40. package/dist/test/dist/repeatTest.js +120 -0
  41. package/dist/test/dist/stringifytest.d.ts +1 -0
  42. package/dist/test/dist/stringifytest.js +8 -0
  43. package/dist/test/dist/test2.d.ts +1 -0
  44. package/dist/test/dist/test2.js +35 -0
  45. package/dist/test/dist/testStream.d.ts +1 -0
  46. package/dist/test/dist/testStream.js +286 -0
  47. package/package.json +3 -1
package/dist/UtilI18n.js CHANGED
@@ -125,7 +125,7 @@ class SI18n {
125
125
  */
126
126
  static getI18n(key, lang) {
127
127
  if (SI18n._table == undefined)
128
- UtilFunctions_1.UtilFunc.throwError('SI18n 未初始化');
128
+ return UtilFunctions_1.UtilFunc.throwError('SI18n 未初始化');
129
129
  let obj = SI18n._table.text_table[key];
130
130
  if (obj == undefined) {
131
131
  UtilLogger_1.SLogger.warn(`SI18n 未在 ${SI18n._dataDir} 找到 ${key} 对应的数据, 已自动添加`);
@@ -1,180 +1 @@
1
- import { Failed, Success, Terminated } from "./UtilSymbol";
2
- /**可以序列化为JSON文件的对象 */
3
- export type JToken = JObject | JArray | JValue | IJData;
4
- /**在stringify输出时 undefine 会被转为 null */
5
- export type JValue = number | string | boolean | null | undefined;
6
- /**在stringify输出时 值为 undefine 的成员会被转为 null */
7
- export type JArray = Array<JToken>;
8
- /**在stringify输出时 值为 undefine 的键会被忽略 */
9
- export type JObject = {
10
- [key: string]: JToken;
11
- };
12
- /**可以保存为JToken的类 */
13
- export interface IJData {
14
- /**保存为JToken
15
- */
16
- toJSON(): JToken;
17
- }
18
- /**任何可能有ReturnType的函数 */
19
- export type AnyFunc = (...args: any) => any;
20
- /**任意可作为键值的类型 */
21
- export type Keyable = string | number | symbol;
22
- /**排除可选项目
23
- * 将基础类型中与默认选项重合的部分变为可选
24
- * @template B - 基础类型
25
- * @template D - 默认选项
26
- */
27
- export type PartialOption<B, D> = keyof D extends keyof B ? Omit<B, keyof D> & Partial<Pick<B, keyof D>> : never;
28
- /**真子集 测试 T 是否为 B 的真子集
29
- * @template B - 超集
30
- * @template T - 子集
31
- */
32
- export type ProperSubset<B, T> = T extends B ? B extends T ? never : T : never;
33
- /**真子集检查 测试 T 是否为 B 的真子集
34
- * 相等时返回 'E'
35
- * 真子集时返回 'P'
36
- * 不相交时返回 'N'
37
- * @template B - 超集
38
- * @template T - 子集
39
- */
40
- export type ProperSubsetCheck<B, T> = T extends B ? B extends T ? "E" : "P" : "N";
41
- /**字面量 检查 L 是否为字面量
42
- * @template L - 目标量
43
- */
44
- export type Literal<L> = ProperSubset<string, L> | ProperSubset<number, L> | ProperSubset<boolean, L> | ProperSubset<symbol, L> | ProperSubset<any[], L> | ProperSubset<Record<any, any>, L> | Extract<L, null | undefined>;
45
- /**字面量检查 测试 L 是否为字面量
46
- * 是字面量时返回 true
47
- * 不是字面量时返回 false
48
- * @template L - 目标量
49
- */
50
- export type LiteralCheck<L> = ProperSubsetCheck<string, L> extends "P" ? true : ProperSubsetCheck<number, L> extends "P" ? true : ProperSubsetCheck<boolean, L> extends "P" ? true : ProperSubsetCheck<symbol, L> extends "P" ? true : ProperSubsetCheck<any[], L> extends "P" ? true : ProperSubsetCheck<Record<any, any>, L> extends "P" ? true : L extends null | undefined ? true : false;
51
- /**递归判断元组 List 每个元素是否 extends T */
52
- export type AllExtends<List extends any[], T> = List extends [infer First, ...infer Rest] ? First extends T ? AllExtends<Rest, T> : false : true;
53
- /**返回将Mixin分配给Base的结果,相同字段时Mixin覆盖Base */
54
- export type AssignObject<Base extends AnyRecord, Mixin extends AnyRecord> = {
55
- [P in keyof Mixin | keyof Base]: P extends keyof Mixin ? Mixin[P] : P extends keyof Base ? Base[P] : never;
56
- };
57
- /**转为可写的 */
58
- export type Writeable<T> = {
59
- -readonly [P in keyof T]: T[P];
60
- };
61
- /**翻转K和V */
62
- export type Inverted<T extends Record<keyof T, string | number | symbol>> = {
63
- [K in keyof T as T[K]]: K;
64
- };
65
- /**N长度 T类型的元组 */
66
- export type FixedLengthTuple<T, N extends number, R extends unknown[] = []> = R['length'] extends N ? R : FixedLengthTuple<T, N, [T, ...R]>;
67
- /**不影响智能补全的任意字符串
68
- * (string&Object)
69
- * (string&String)
70
- */
71
- export type AnyString = (string & {});
72
- /**联合类型转为交叉类型
73
- * 利用分布式条件将U展开为联合函数(k:U1)=>void | (k:U2)=>void
74
- * 再从中提取可以传递给任意联合函数的类型
75
- */
76
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
77
- /**创建一个新的类型,这个新的类型包含了基础类型 B 的所有属性,
78
- * 以及一个名为 K[N] 类型为 T 的新属性。
79
- * 所有 K 中非 K[N] 的其他属性都是可选的并且不能被赋值(因为它们的类型是 never)。
80
- */
81
- type ExclusiveSub<B, T, K extends string[], N extends number> = B & {
82
- [P in K[N]]: T;
83
- } & {
84
- [P in Exclude<K[number], K[N]>]?: never;
85
- };
86
- /**递归地创建一个元组类型, 所有成员类型都有一个 K[number] 键 并且与其他成员互斥
87
- * 这个元组类型的每个元素都是通过 ExclusiveSub 类型创建的。
88
- */
89
- type ExclusiveRecursive<B, T, K extends string[], R extends unknown[] = []> = R['length'] extends K['length'] ? R : ExclusiveRecursive<B, T, K, [ExclusiveSub<B, T, K, R['length']>, ...R]>;
90
- /**互斥表
91
- * 从 ExclusiveRecursive 类型创建的元组中创建一个或类型, 可以是任意一个元组元素类型
92
- */
93
- export type ExclusiveRecord<B, T, K extends string[], TMP = ExclusiveRecursive<B, T, K>> = TMP[keyof TMP];
94
- /**符合JObject约束的互斥表 */
95
- export type ExclusiveJObject<B extends JObject, T extends JToken, K extends string[], TMP extends JArray = ExclusiveRecursive<B, T, K>> = TMP[number];
96
- /**Promise完成状态 成功/失败/终止
97
- * 成功 将直接返回 结果
98
- * 终止 将直接返回 结果
99
- * 失败 将重试
100
- */
101
- export type PromiseStatus = Success | Failed | Terminated;
102
- /**状态验证函数 */
103
- export type StatusVerifyFn<T> = (obj: T) => Promise<PromiseStatus> | PromiseStatus;
104
- /**获取Promise的结果类型 如同await那样
105
- * @deprecated 请使用官方的 Awaited<T> 类型
106
- */
107
- export type Await<T> = T extends Promise<infer U> ? U : T;
108
- /**类型中任意函数的字符串名称 */
109
- export type FuncPropNames<T> = {
110
- [K in keyof T]: T[K] extends AnyFunc ? K : never;
111
- }[keyof T];
112
- /** extends封装
113
- * @template B - 基础类型
114
- * @template T - 判断的目标类型
115
- * @template Y - 如果为真的返回值
116
- * @template N - 如果为假的返回值
117
- */
118
- export type ExtendThen<B, T, Y, N = never> = B extends T ? Y : N;
119
- /**排除可选字段 */
120
- export type RequiredOnly<T> = {
121
- [K in keyof T as T[K] extends Exclude<T[K], undefined> ? K : never]: T[K];
122
- };
123
- /**添加前缀 */
124
- export type WithPrefix<T, P extends string> = {
125
- [K in (keyof T) as K extends string ? `${P}${K}` : K]: T[K];
126
- };
127
- /**附带状态的返回结果用于状态返回值的封装
128
- * @template K - 类型键值
129
- * @template V - 值
130
- */
131
- export type Outcome<K extends Keyable, V> = {
132
- /**状态类型 */
133
- readonly status: K;
134
- /**值 */
135
- readonly result: V;
136
- };
137
- /**可进行匹配的对象
138
- * 如果是Outcome则自动处理status
139
- */
140
- export type Matchable<T extends Keyable> = T | Outcome<T, unknown>;
141
- /**可进行匹配的 outcome或symbol 中的状态类型 */
142
- export type MatchableFlag<T> = T extends infer O | Outcome<infer O, unknown> ? O : never;
143
- /**从联合 Outcome 中 根据 K 提取对应 Outcome
144
- * @template T - 联合Outcome匹配的类型
145
- * @template K - 所需的状态
146
- */
147
- export type ExtractOutcome<T, K extends Keyable> = T extends Outcome<infer O, unknown> ? O extends Exclude<O, K> ? never : T : never;
148
- /**用于辅助解析智能补全的类型
149
- * 输出schema后替换为 ^.*$ 的 string 匹配
150
- */
151
- export type SchemaString = `${string}SchemaString`;
152
- /**需要初始化 */
153
- export type NeedInit = {
154
- /**完成初始化的标记 */
155
- inited: Promise<any>;
156
- };
157
- /**可选的record PartialRecord */
158
- export type PRecord<K extends Keyable, V> = Partial<Record<K, V>>;
159
- /** 可以是Promise MaybePromise*/
160
- export type MPromise<T> = T | Promise<T>;
161
- /**任何Record */
162
- export type AnyRecord = Record<Keyable, any>;
163
- /**注释元组
164
- * @template T - 提供注释的类型, 索引需从0开始
165
- */
166
- export type CmtTuple<T extends {
167
- [K: number]: unknown;
168
- }, Tuple extends unknown[] = []> = unknown extends T[Tuple['length']] ? T & Tuple : CmtTuple<T, [...Tuple, T[Tuple['length']]]>;
169
- /**非严格模式下将会判断为false的值, 不包含NaN */
170
- export type Flasy = false | 0 | -0 | "" | null | undefined;
171
- /**srt段 */
172
- export type SrtSegment = {
173
- /**开始时间, 以毫秒为单位 */
174
- start: number;
175
- /**结束时间, 以毫秒为单位 */
176
- end: number;
177
- /**字幕文本 */
178
- text: string;
179
- };
180
- export {};
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,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //#endregion
@@ -1,3 +1,4 @@
1
+ import { LogLevel } from './UtilInterfaces';
1
2
  /**hrtime所产生的的记录 */
2
3
  export type HRTimeLog = {
3
4
  /**秒数 */
@@ -5,8 +6,6 @@ export type HRTimeLog = {
5
6
  /**纳秒数 */
6
7
  1: number;
7
8
  };
8
- /**log等级 undefined相当于 silly */
9
- export type LogLevel = "fatal" | "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly" | undefined;
10
9
  export declare class SLogger {
11
10
  /**获取一个Logger,如不存在则用默认参数创建
12
11
  * @param name - logger的名称 默认default
@@ -32,47 +31,47 @@ export declare class SLogger {
32
31
  * @param messages - log消息
33
32
  * @returns 自身
34
33
  */
35
- log(level: LogLevel, ...messages: Array<any>): SLogger;
34
+ log(level: LogLevel, ...messages: any[]): SLogger;
36
35
  /**产生一条fatal等级的log 返回自身
37
36
  * @param messages - log消息
38
37
  * @returns 自身
39
38
  */
40
- fatal(...messages: Array<any>): SLogger;
39
+ fatal(...messages: any[]): SLogger;
41
40
  /**产生一条error等级的log 返回自身
42
41
  * @param messages - log消息
43
42
  * @returns 自身
44
43
  */
45
- error(...messages: Array<any>): SLogger;
44
+ error(...messages: any[]): SLogger;
46
45
  /**产生一条warn等级的log 返回自身
47
46
  * @param messages - log消息
48
47
  * @returns 自身
49
48
  */
50
- warn(...messages: Array<any>): SLogger;
49
+ warn(...messages: any[]): SLogger;
51
50
  /**产生一条info等级的log 返回自身
52
51
  * @param messages - log消息
53
52
  * @returns 自身
54
53
  */
55
- info(...messages: Array<any>): SLogger;
54
+ info(...messages: any[]): SLogger;
56
55
  /**产生一条http等级的log 返回自身
57
56
  * @param messages - log消息
58
57
  * @returns 自身
59
58
  */
60
- http(...messages: Array<any>): SLogger;
59
+ http(...messages: any[]): SLogger;
61
60
  /**产生一条verbose等级的log 返回自身
62
61
  * @param messages - log消息
63
62
  * @returns 自身
64
63
  */
65
- verbose(...messages: Array<any>): SLogger;
64
+ verbose(...messages: any[]): SLogger;
66
65
  /**产生一条debug等级的log 返回自身
67
66
  * @param messages - log消息
68
67
  * @returns 自身
69
68
  */
70
- debug(...messages: Array<any>): SLogger;
69
+ debug(...messages: any[]): SLogger;
71
70
  /**产生一条silly等级的log 返回自身
72
71
  * @param messages - log消息
73
72
  * @returns 自身
74
73
  */
75
- silly(...messages: Array<any>): SLogger;
74
+ silly(...messages: any[]): SLogger;
76
75
  /**记录当前时间戳并存入表
77
76
  * @param flag - 记录的命名
78
77
  * @returns 记录的时间
@@ -91,47 +90,47 @@ export declare class SLogger {
91
90
  * @param messages - log消息
92
91
  * @returns 自身
93
92
  */
94
- static log(level: LogLevel, ...messages: Array<any>): SLogger;
93
+ static log(level: LogLevel, ...messages: any[]): SLogger;
95
94
  /**让名称为default的logger 产生一条fatal等级的log 返回自身
96
95
  * @param messages - log消息
97
96
  * @returns 自身
98
97
  */
99
- static fatal(...messages: Array<any>): SLogger;
98
+ static fatal(...messages: any[]): SLogger;
100
99
  /**让名称为default的logger 产生一条error等级的log 返回自身
101
100
  * @param messages - log消息
102
101
  * @returns 自身
103
102
  */
104
- static error(...messages: Array<any>): SLogger;
103
+ static error(...messages: any[]): SLogger;
105
104
  /**让名称为default的logger 产生一条warn等级的log 返回自身
106
105
  * @param messages - log消息
107
106
  * @returns 自身
108
107
  */
109
- static warn(...messages: Array<any>): SLogger;
108
+ static warn(...messages: any[]): SLogger;
110
109
  /**让名称为default的logger 产生一条info等级的log 返回自身
111
110
  * @param messages - log消息
112
111
  * @returns 自身
113
112
  */
114
- static info(...messages: Array<any>): SLogger;
113
+ static info(...messages: any[]): SLogger;
115
114
  /**让名称为default的logger 产生一条http等级的log 返回自身
116
115
  * @param messages - log消息
117
116
  * @returns 自身
118
117
  */
119
- static http(...messages: Array<any>): SLogger;
118
+ static http(...messages: any[]): SLogger;
120
119
  /**让名称为default的logger 产生一条verbose等级的log 返回自身
121
120
  * @param messages - log消息
122
121
  * @returns 自身
123
122
  */
124
- static verbose(...messages: Array<any>): SLogger;
123
+ static verbose(...messages: any[]): SLogger;
125
124
  /**让名称为default的logger 产生一条debug等级的log 返回自身
126
125
  * @param messages - log消息
127
126
  * @returns 自身
128
127
  */
129
- static debug(...messages: Array<any>): SLogger;
128
+ static debug(...messages: any[]): SLogger;
130
129
  /**让名称为default的logger 产生一条silly等级的log 返回自身
131
130
  * @param messages - log消息
132
131
  * @returns 自身
133
132
  */
134
- static silly(...messages: Array<any>): SLogger;
133
+ static silly(...messages: any[]): SLogger;
135
134
  /**让名称为default的logger 记录当前时间戳并存入表
136
135
  * @param flag - 记录的命名
137
136
  * @returns 记录的时间
@@ -79,7 +79,7 @@ class SLogger {
79
79
  //格式化
80
80
  //let format = `[${info.timestamp}] [${level}]: `
81
81
  //let space = " ".repeat(format.length);
82
- let messageList = message.split("\n");
82
+ const messageList = message.split("\n");
83
83
  return `[${info.timestamp}] [${level.toUpperCase()}]: ${messageList.join("\n")}`;
84
84
  }));
85
85
  transports.push(new winston_daily_rotate_file_1.default({
@@ -1,40 +1 @@
1
- import { Outcome } from "./UtilInterfaces";
2
- /**成功 经过验证的结果 */
3
- export declare const Success: unique symbol;
4
- export type Success = typeof Success;
5
- /**失败 可重试的 */
6
- export declare const Failed: unique symbol;
7
- export type Failed = typeof Failed;
8
- /**不存在 无 */
9
- export declare const None: unique symbol;
10
- export type None = typeof None;
11
- /**未初始化的 用于静态构造函数标记*/
12
- export declare const Uninited: unique symbol;
13
- export type Uninited = typeof Uninited;
14
- /**完成 未经验证/未超时的结果
15
- * Success扩展
16
- * 仅在Success同时出现时使用
17
- */
18
- export declare const Completed: unique symbol;
19
- export type Completed = typeof Completed;
20
- /**终止 熔断运行
21
- * Failed扩展
22
- * 仅在Failed同时出现时使用
23
- */
24
- export declare const Terminated: unique symbol;
25
- export type Terminated = typeof Terminated;
26
- /**超时 超时类型的失败
27
- * Failed扩展
28
- * 仅在超时时使用
29
- */
30
- export declare const Timeout: unique symbol;
31
- export type Timeout = typeof Timeout;
32
- /**失败及其拓展 */
33
- export type FailedLike = Failed | Timeout | Terminated;
34
- /**成功及其拓展 */
35
- export type SuccessLike = Success | Completed;
36
- /**任意状态标识符 */
37
- export type StatusSymbol = FailedLike | SuccessLike | None | Uninited;
38
- /**结果为 None 的 Outcome */
39
- export type NoneOut = Outcome<None, None>;
40
- export declare const NoneOut: NoneOut;
1
+ export { Success, Failed, None, Uninited, Completed, Terminated, Timeout, FailedLike, SuccessLike, StatusSymbol, NoneOut } from "@zwa73/js-utils";
@@ -1,30 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NoneOut = exports.Timeout = exports.Terminated = exports.Completed = exports.Uninited = exports.None = exports.Failed = exports.Success = void 0;
4
- /**成功 经过验证的结果 */
5
- exports.Success = Symbol("Success");
6
- /**失败 可重试的 */
7
- exports.Failed = Symbol("Failed");
8
- /**不存在 */
9
- exports.None = Symbol("None");
10
- /**未初始化的 用于静态构造函数标记*/
11
- exports.Uninited = Symbol("Uninited");
12
- /**完成 未经验证/未超时的结果
13
- * Success扩展
14
- * 仅在Success同时出现时使用
15
- */
16
- exports.Completed = Symbol("Completed");
17
- /**终止 熔断运行
18
- * Failed扩展
19
- * 仅在Failed同时出现时使用
20
- */
21
- exports.Terminated = Symbol("Terminated");
22
- /**超时 超时类型的失败
23
- * Failed扩展
24
- * 仅在超时时使用
25
- */
26
- exports.Timeout = Symbol("Timeout");
27
- exports.NoneOut = {
28
- status: exports.None,
29
- result: exports.None,
30
- };
4
+ //#region UtilSymbol转导
5
+ var js_utils_1 = require("@zwa73/js-utils");
6
+ Object.defineProperty(exports, "Success", { enumerable: true, get: function () { return js_utils_1.Success; } });
7
+ Object.defineProperty(exports, "Failed", { enumerable: true, get: function () { return js_utils_1.Failed; } });
8
+ Object.defineProperty(exports, "None", { enumerable: true, get: function () { return js_utils_1.None; } });
9
+ Object.defineProperty(exports, "Uninited", { enumerable: true, get: function () { return js_utils_1.Uninited; } });
10
+ Object.defineProperty(exports, "Completed", { enumerable: true, get: function () { return js_utils_1.Completed; } });
11
+ Object.defineProperty(exports, "Terminated", { enumerable: true, get: function () { return js_utils_1.Terminated; } });
12
+ Object.defineProperty(exports, "Timeout", { enumerable: true, get: function () { return js_utils_1.Timeout; } });
13
+ Object.defineProperty(exports, "NoneOut", { enumerable: true, get: function () { return js_utils_1.NoneOut; } });
14
+ //#endregion
package/dist/index.js CHANGED
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ const UtilLogger_1 = require("./UtilLogger");
18
+ const js_utils_1 = require("@zwa73/js-utils");
19
+ js_utils_1.JsUtilsInject.setLogger(UtilLogger_1.SLogger);
17
20
  __exportStar(require("./UtilFunctions"), exports);
18
21
  __exportStar(require("./UtilInterfaces"), exports);
19
22
  __exportStar(require("./UtilSymbol"), exports);
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,153 @@
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; //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,11 @@
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)); //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,21 @@
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);
@@ -0,0 +1 @@
1
+ export const __esModule: true;
@@ -0,0 +1,14 @@
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; //?
@@ -0,0 +1 @@
1
+ export const __esModule: true;