@aitianyu.cn/types 0.1.2 → 0.1.3

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 (66) hide show
  1. package/README.md +44 -0
  2. package/dist/lib/coding/Error.js +16 -6
  3. package/dist/lib/coding/Path.js +41 -20
  4. package/dist/lib/core/Environment.js +14 -0
  5. package/dist/lib/core/Errors.js +34 -13
  6. package/dist/lib/core/Language.js +60 -7
  7. package/dist/lib/core/Log.js +34 -2
  8. package/dist/lib/core/TypeConvertion.js +20 -0
  9. package/dist/lib/core/object/ArrayHelper.js +15 -4
  10. package/dist/lib/core/object/Bytes.js +8 -4
  11. package/dist/lib/core/object/Calculater.js +109 -44
  12. package/dist/lib/core/object/DataView.js +13 -4
  13. package/dist/lib/core/object/Integer.js +57 -36
  14. package/dist/lib/core/object/Json.js +22 -10
  15. package/dist/lib/core/object/ObjectHelper.js +38 -14
  16. package/dist/lib/core/object/StringHelper.js +35 -8
  17. package/dist/lib/index.js +47 -6
  18. package/dist/lib/security/Base32.js +22 -13
  19. package/dist/lib/security/Guid.js +18 -1
  20. package/dist/lib/security/Hash.js +10 -1
  21. package/dist/lib/security/QRCode.js +16 -4
  22. package/dist/lib/security/RSA.js +33 -20
  23. package/dist/lib/security/SHA.js +25 -15
  24. package/dist/lib/security/TOTP.js +31 -9
  25. package/dist/lib/types/AreaCode.js +140 -131
  26. package/dist/lib/types/Exception.js +17 -3
  27. package/dist/lib/types/Logs.js +13 -7
  28. package/dist/lib/types/PathBase.js +43 -23
  29. package/dist/lib/types/Security.js +6 -1
  30. package/dist/lib/types/TMap.js +48 -30
  31. package/dist/types/coding/Error.d.ts +16 -6
  32. package/dist/types/coding/Path.d.ts +45 -21
  33. package/dist/types/core/Environment.d.ts +14 -0
  34. package/dist/types/core/Errors.d.ts +34 -13
  35. package/dist/types/core/Language.d.ts +33 -7
  36. package/dist/types/core/Log.d.ts +34 -2
  37. package/dist/types/core/TypeConvertion.d.ts +20 -0
  38. package/dist/types/core/interface/ITJSON.d.ts +11 -0
  39. package/dist/types/core/interface/ITianyuType.d.ts +11 -0
  40. package/dist/types/core/object/ArrayHelper.d.ts +15 -4
  41. package/dist/types/core/object/Bytes.d.ts +8 -4
  42. package/dist/types/core/object/Calculater.d.ts +38 -10
  43. package/dist/types/core/object/DataView.d.ts +13 -4
  44. package/dist/types/core/object/Integer.d.ts +57 -36
  45. package/dist/types/core/object/Json.d.ts +22 -10
  46. package/dist/types/core/object/ObjectHelper.d.ts +38 -14
  47. package/dist/types/core/object/StringHelper.d.ts +35 -8
  48. package/dist/types/index.d.ts +44 -0
  49. package/dist/types/security/Base32.d.ts +31 -18
  50. package/dist/types/security/Guid.d.ts +19 -1
  51. package/dist/types/security/Hash.d.ts +10 -1
  52. package/dist/types/security/QRCode.d.ts +16 -4
  53. package/dist/types/security/RSA.d.ts +51 -28
  54. package/dist/types/security/SHA.d.ts +25 -15
  55. package/dist/types/security/TOTP.d.ts +31 -9
  56. package/dist/types/types/AreaCode.d.ts +140 -1
  57. package/dist/types/types/Exception.d.ts +17 -3
  58. package/dist/types/types/Logs.d.ts +59 -30
  59. package/dist/types/types/Object.d.ts +16 -7
  60. package/dist/types/types/PathBase.d.ts +43 -23
  61. package/dist/types/types/Security.d.ts +21 -8
  62. package/dist/types/types/TMap.d.ts +48 -30
  63. package/dist/types/types/Types.d.ts +42 -10
  64. package/doc/en/README.md +372 -0
  65. package/doc/zh/README.md +372 -0
  66. package/package.json +3 -2
@@ -3,41 +3,50 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.TMap = void 0;
5
5
  /**
6
- * Tianyu Map
7
- * Support Customized Object type
6
+ * Tianyu Map — a generic Map implementation that supports customized object types as keys.
7
+ * Keys must implement IComparable; the getString() value is used internally as the actual map key.
8
+ *
9
+ * Tianyu 映射表——支持自定义对象类型作为键的泛型 Map 实现。
10
+ * 键必须实现 IComparable 接口;内部使用 getString() 返回值作为实际映射键。
8
11
  */
9
12
  class TMap {
13
+ /** Internal value store keyed by the string form of K. / 以 K 的字符串形式为键的内部值存储。 */
10
14
  _map;
15
+ /** Internal key object store for retrieving the original K instance. / 存储原始 K 实例的内部键对象映射。 */
11
16
  _kMap;
12
17
  /**
13
- * Create an empty Tianyu Map Instance
18
+ * Create an empty TMap instance.
19
+ * 创建一个空的 TMap 实例。
14
20
  */
15
21
  constructor() {
16
22
  this._map = new Map();
17
23
  this._kMap = new Map();
18
24
  }
19
25
  /**
20
- * Clean the Map instance
26
+ * Remove all key-value pairs from the map.
27
+ * 清除映射表中的所有键值对。
21
28
  */
22
29
  clear() {
23
30
  this._map.clear();
24
31
  this._kMap.clear();
25
32
  }
26
33
  /**
27
- * Delete a specified item from the instance
34
+ * Delete the element with the specified key from the map.
35
+ * 从映射表中删除指定键对应的元素。
28
36
  *
29
- * @param key The key of the item
30
- * @returns return true if deleted successful and return false if failed
37
+ * @param key the key of the element to delete / 要删除的元素的键
38
+ * @returns true if the element was found and deleted, false otherwise / 删除成功返回 true,否则返回 false
31
39
  */
32
40
  delete(key) {
33
41
  const keyString = key.getString();
34
42
  return this._map.delete(keyString) && this._kMap.delete(keyString);
35
43
  }
36
44
  /**
37
- * Executes a provided function once per each key/value pair in the Map, in insertion order.
45
+ * Execute a callback once for each key-value pair in insertion order.
46
+ * 按插入顺序对每个键值对执行一次回调函数。
38
47
  *
39
- * @param callbackfn provided execution function
40
- * @param thisArg additional args
48
+ * @param callbackfn the function to execute per entry / 每条记录执行的回调函数
49
+ * @param thisArg optional value to use as `this` in the callback / 回调中可选的 this 绑定值
41
50
  */
42
51
  forEach(callbackfn, thisArg) {
43
52
  const runMap = new Map();
@@ -52,33 +61,38 @@ class TMap {
52
61
  }, thisArg);
53
62
  }
54
63
  /**
55
- * Returns a specified element from the Map object. If the value that is associated to the provided key is an object,
56
- * then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
64
+ * Return the value associated with the specified key.
65
+ * If the key is associated with an object, a reference to that object is returned
66
+ * any mutation will affect the stored value.
57
67
  *
58
- * @param key The key of the value
59
- * @returns Returns the element associated with the specified key.
60
- * If no element is associated with the specified key, undefined is returned.
68
+ * 返回与指定键关联的值。
69
+ * 若键对应的值为对象,则返回其引用——对该对象的修改会影响映射表中存储的值。
70
+ *
71
+ * @param key the key to look up / 要查找的键
72
+ * @returns the associated value, or undefined if not found / 关联的值,未找到时返回 undefined
61
73
  */
62
74
  get(key) {
63
75
  const keyString = key.getString();
64
76
  return this._map.get(keyString);
65
77
  }
66
78
  /**
67
- * Get a boolean value indicates whether an element with the specified key exists or not.
79
+ * Check whether an element with the specified key exists in the map.
80
+ * 检查映射表中是否存在指定键对应的元素。
68
81
  *
69
- * @param key The key what wants to search
70
- * @returns return true if the value is found
82
+ * @param key the key to search for / 要查找的键
83
+ * @returns true if the key exists / 键存在时返回 true
71
84
  */
72
85
  has(key) {
73
86
  const keyString = key.getString();
74
87
  return this._kMap.has(keyString);
75
88
  }
76
89
  /**
77
- * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
90
+ * Add or update the element with the specified key and value.
91
+ * 添加或更新具有指定键和值的元素。
78
92
  *
79
- * @param key The key of new element
80
- * @param value The value of new element
81
- * @returns return the instance that is current instance
93
+ * @param key the key of the new or existing element / 新增或已有元素的键
94
+ * @param value the value to associate with the key / 要与键关联的值
95
+ * @returns the current TMap instance (for chaining) / 当前 TMap 实例(支持链式调用)
82
96
  */
83
97
  set(key, value) {
84
98
  const keyString = key.getString();
@@ -87,33 +101,37 @@ class TMap {
87
101
  return this;
88
102
  }
89
103
  /**
90
- * Get a number of elements in the Map
104
+ * Get the number of elements stored in the map.
105
+ * 获取映射表中存储的元素数量。
91
106
  *
92
- * @returns return the count of elements
107
+ * @returns the element count / 元素数量
93
108
  */
94
109
  size() {
95
110
  return this._kMap.size;
96
111
  }
97
112
  /**
98
- * Get all keys of the Map
113
+ * Return an iterator over all keys (as original K instances) in the map.
114
+ * 返回映射表中所有键(原始 K 实例)的迭代器。
99
115
  *
100
- * @returns return a keys iterator
116
+ * @returns a keys iterator / 键迭代器
101
117
  */
102
118
  keys() {
103
119
  return this._kMap.values();
104
120
  }
105
121
  /**
106
- * Get all values of the Map
122
+ * Return an iterator over all values in the map.
123
+ * 返回映射表中所有值的迭代器。
107
124
  *
108
- * @returns return a values iterator
125
+ * @returns a values iterator / 值迭代器
109
126
  */
110
127
  values() {
111
128
  return this._map.values();
112
129
  }
113
130
  /**
114
- * Get an Iterator of the Map
131
+ * Return an iterator that yields [K, V] tuple pairs in insertion order.
132
+ * 返回按插入顺序产出 [K, V] 元组对的迭代器。
115
133
  *
116
- * @returns return an iterator object
134
+ * @returns an iterator object / 迭代器对象
117
135
  */
118
136
  [Symbol.iterator]() {
119
137
  const keys = this._map.entries();
@@ -2,26 +2,36 @@
2
2
  import { Exception } from "../types/Exception";
3
3
  import { PathTargetType } from "./Path";
4
4
  /**
5
- * Source lost exception of Path Processor.
6
- * Exception will be thrown if the path is file but the file field is not specified
5
+ * Thrown when a Path instance is typed as "file" but no file name has been provided.
6
+ * Path 实例的类型为 "file" 但未指定文件名时抛出此异常。
7
7
  */
8
8
  export declare class PathProcessorSourceLostException extends Exception {
9
+ /**
10
+ * @param msg optional additional message / 可选的附加信息
11
+ */
9
12
  constructor(msg?: string);
10
13
  toString(): string;
11
14
  }
12
15
  /**
13
- * Path directory name is not valid.
14
- * Exception will be thrown if the path name has the invalid char
16
+ * Thrown when a path segment contains characters that are not valid in a directory name.
17
+ * 当路径段中包含目录名非法字符时抛出此异常。
15
18
  */
16
19
  export declare class PathDirectoryValidationFailException extends Exception {
20
+ /**
21
+ * @param msg the invalid directory name / 非法的目录名
22
+ */
17
23
  constructor(msg?: string);
18
24
  toString(): string;
19
25
  }
20
26
  /**
21
- * Path is file or directory but target type is not.
22
- * Exception will be thrown if the path is file(directory) but try to convert to directory(file)
27
+ * Thrown when attempting to treat a file path as a directory path or vice versa.
28
+ * 当尝试将文件路径当作目录路径(或反之)进行转换时抛出此异常。
23
29
  */
24
30
  export declare class PathDirAndFileConvertInvaild extends Exception {
31
+ /**
32
+ * @param path the path string that caused the conflict / 引发冲突的路径字符串
33
+ * @param type the actual type of the path / 路径的实际类型
34
+ */
25
35
  constructor(path: string, type: PathTargetType);
26
36
  toString(): string;
27
37
  }
@@ -1,61 +1,85 @@
1
1
  /**@format */
2
2
  import { PathBase } from "../types/PathBase";
3
3
  import { IComparable } from "../types/Types";
4
- /** The target path type */
4
+ /**
5
+ * The target type of a Path — either a directory or a file.
6
+ * Path 的目标类型——目录或文件。
7
+ */
5
8
  export type PathTargetType = "directory" | "file";
6
- /** Path */
9
+ /**
10
+ * Represents a file system path with explicit type (directory or file).
11
+ * Supports construction from a string, an array of segments, or a combination.
12
+ * Throws validation exceptions for invalid segment characters or type mismatches.
13
+ *
14
+ * 表示具有明确类型(目录或文件)的文件系统路径。
15
+ * 支持从字符串、目录段数组或两者组合构建实例。
16
+ * 遇到非法字符或类型不匹配时会抛出校验异常。
17
+ */
7
18
  export declare class Path extends PathBase implements IComparable {
19
+ /** Internal path type indicator. / 内部路径类型标识。 */
8
20
  private _type;
21
+ /** The file name component, present only when type is "file". / 文件名组件,仅在类型为 "file" 时存在。 */
9
22
  private _file?;
10
23
  /**
11
- * Create a new Path instance
24
+ * Create a new Path instance.
25
+ * 创建一个新的 Path 实例。
12
26
  *
13
- * @param dirs the directory names
14
- * @param type indicate which type the Path is
15
- * @param file the file name if the type is file
27
+ * @param dirs directory segments as an array or a full path string / 目录段数组或完整路径字符串
28
+ * @param type explicit target type; inferred from string if omitted / 显式目标类型,省略时从字符串推断
29
+ * @param file explicit file name when type is "file" / 类型为 "file" 时指定文件名
16
30
  */
17
31
  constructor(dirs?: string[] | string, type?: PathTargetType, file?: string);
18
32
  /**
19
- * Convert the path to a string
33
+ * Convert this path to its string representation.
34
+ * Throws PathProcessorSourceLostException if type is "file" but no file name is set.
20
35
  *
21
- * @returns return the string
36
+ * 将路径转换为字符串表示形式。
37
+ * 若类型为 "file" 但未设置文件名,则抛出 PathProcessorSourceLostException。
38
+ *
39
+ * @returns the formatted path string / 格式化后的路径字符串
22
40
  */
23
41
  toString(): string;
24
42
  /**
25
- * Set the target type
43
+ * Set the target type of this path instance.
44
+ * 设置当前路径实例的目标类型。
26
45
  *
27
- * @param type new type
46
+ * @param type the new path type / 新路径类型
28
47
  */
29
48
  setType(type: PathTargetType): void;
30
49
  /**
31
- * Get the path type of current instance
50
+ * Get the target type of this path instance.
51
+ * 获取当前路径实例的目标类型。
32
52
  *
33
- * @returns return the path type
53
+ * @returns the path type / 路径类型
34
54
  */
35
55
  getType(): PathTargetType;
36
56
  /**
37
- * Set the path file name
57
+ * Set a new file name for this path.
58
+ * 设置当前路径的新文件名。
38
59
  *
39
- * @param file the new file name
40
- * @returns return the old file name
60
+ * @param file the new file name / 新文件名
61
+ * @returns the previous file name, or undefined if none was set / 之前的文件名,未设置时返回 undefined
41
62
  */
42
63
  setFile(file: string): string | undefined;
43
64
  /**
44
- * Get the file name of current instance
65
+ * Get the file name component of this path.
66
+ * 获取当前路径的文件名组件。
45
67
  *
46
- * @returns return the file name
68
+ * @returns the file name, or undefined if this is a directory path / 文件名,若为目录路径则返回 undefined
47
69
  */
48
70
  getFile(): string | undefined;
49
71
  /**
50
- * IComparable impl to get a string what equals to current instance
72
+ * IComparable implementation returns the string form for equality comparison.
73
+ * IComparable 实现——返回用于相等性比较的字符串形式。
51
74
  *
52
- * @returns return the string
75
+ * @returns the comparable string / 可比较字符串
53
76
  */
54
77
  getString(): string;
55
78
  /**
56
- * Get a hash code of current instance
79
+ * IComparable implementation returns 0 as the hash code.
80
+ * IComparable 实现——返回 0 作为哈希码。
57
81
  *
58
- * @returns always return 0
82
+ * @returns always 0 / 始终返回 0
59
83
  */
60
84
  getHashCode(): number;
61
85
  }
@@ -1,4 +1,18 @@
1
1
  /** @format */
2
+ /**
3
+ * Runtime environment detection utility.
4
+ * Identifies whether the current execution context is Node.js or a browser.
5
+ *
6
+ * 运行时环境检测工具类。
7
+ * 用于识别当前执行上下文是 Node.js 还是浏览器环境。
8
+ */
2
9
  export declare class Environment {
10
+ /**
11
+ * Detect the current runtime environment.
12
+ * 检测当前运行时环境。
13
+ *
14
+ * @returns "node" when running in Node.js, "browser" otherwise
15
+ * 在 Node.js 中运行时返回 "node",否则返回 "browser"
16
+ */
3
17
  static runtimeEnv(): "node" | "browser";
4
18
  }
@@ -1,47 +1,68 @@
1
1
  /**@format */
2
2
  import { Exception } from "../types/Exception";
3
- /** Argument null exception */
3
+ /**
4
+ * Thrown when a required argument is null or an empty string.
5
+ * 当必填参数为 null 或空字符串时抛出。
6
+ */
4
7
  export declare class ArgumentNullOrEmptyException extends Exception {
8
+ /**
9
+ * @param msg the name of the offending argument / 出错的参数名称
10
+ */
5
11
  constructor(msg: string);
6
12
  toString(): string;
7
13
  }
8
14
  /**
9
- * Object Clone:
10
- * Function type is not supported.
11
- * Exception will be thrown if try to clone a function type object
15
+ * Thrown when attempting to deep-clone an object that contains a function value.
16
+ * Function types are not supported by the clone utility.
17
+ *
18
+ * 当尝试深度克隆包含函数值的对象时抛出。
19
+ * 克隆工具不支持 function 类型。
12
20
  */
13
21
  export declare class ObjectCloneFunctionNotSupportException extends Exception {
14
22
  constructor();
15
23
  toString(): string;
16
24
  }
17
25
  /**
18
- * Object Clone:
19
- * Object different status could not be matched.
20
- * Exception will be thrown if the object diff could not to be merged
26
+ * Thrown when the expected state of an object diff entry does not match
27
+ * the actual current state during a merge operation.
28
+ *
29
+ * 在合并操作中,对象差异条目的预期状态与当前实际状态不匹配时抛出。
21
30
  */
22
31
  export declare class ObjectMergeStatusCheckFailedException extends Exception {
23
32
  private status;
24
33
  private path;
34
+ /**
35
+ * @param path the diff path where the mismatch occurred / 发生不匹配的差异路径
36
+ * @param status the type of change that failed verification / 校验失败的变更类型
37
+ */
25
38
  constructor(path: string, status: "add" | "modify" | "del");
26
39
  toString(): string;
27
40
  }
28
41
  /**
29
- * Object Clone:
30
- * Object different status could not be applied.
31
- * Exception will be thrown if the object diff could not to be applied
42
+ * Thrown when a diff entry cannot be applied because the current value
43
+ * is in an unexpected state (e.g., a value that should not exist already does).
44
+ *
45
+ * 当差异条目因当前值处于意外状态(如不应存在的值已存在)而无法应用时抛出。
32
46
  */
33
47
  export declare class ObjectDiffApplyInvalidStatusException extends Exception {
34
48
  private value;
49
+ /**
50
+ * @param value the value that is in an invalid state / 处于无效状态的值
51
+ */
35
52
  constructor(value: any);
36
53
  toString(): string;
37
54
  }
38
55
  /**
39
- * Object Clone:
40
- * Object different merge failed.
41
- * Exception will be thrown if the object element could not be accessed
56
+ * Thrown when a nested object at a specific path cannot be accessed during a diff merge,
57
+ * typically because an intermediate parent object is missing.
58
+ *
59
+ * 在差异合并期间,因中间父对象缺失等原因导致特定路径处的嵌套对象无法访问时抛出。
42
60
  */
43
61
  export declare class ObjectDiffMergeFailedException extends Exception {
44
62
  private path;
63
+ /**
64
+ * @param path the path where the inaccessible object was encountered / 遇到无法访问对象的路径
65
+ */
45
66
  constructor(path: string);
46
67
  toString(): string;
47
68
  }
@@ -1,17 +1,43 @@
1
1
  /**@format */
2
2
  import { AreaCode } from "../types/AreaCode";
3
3
  /**
4
- * Parse area code to general string
4
+ * Convert an AreaCode enum value to its canonical locale string (e.g. "zh_CN", "en_US").
5
+ * Falls back to "zh_CN" for AreaCode.unknown.
5
6
  *
6
- * @param eArea the area code
7
- * @returns return the general string of specified area code
7
+ * AreaCode 枚举值转换为其标准语言环境字符串(如 "zh_CN"、"en_US")。
8
+ * AreaCode.unknown 回退为 "zh_CN"。
9
+ *
10
+ * @param eArea the AreaCode enum value / AreaCode 枚举值
11
+ * @returns the locale string for the given area code / 给定区域码对应的语言环境字符串
12
+ *
13
+ * @example
14
+ * parseAreaCode(AreaCode.zh_CN); // "zh_CN"
15
+ * parseAreaCode(AreaCode.en_US); // "en_US"
8
16
  */
9
17
  export declare function parseAreaCode(eArea: AreaCode): string;
10
18
  /**
11
- * Convert the string to area code
19
+ * Parse a locale string into its corresponding AreaCode enum value.
20
+ * The input is matched case-insensitively (e.g. "ZH_CN", "zh_cn", and "zh_CN" all resolve to AreaCode.zh_CN).
21
+ *
22
+ * When the string cannot be matched:
23
+ * - `forceArea` omitted or false → returns AreaCode.zh_CN (lenient default)
24
+ * - `forceArea` true → returns AreaCode.unknown (strict mode)
25
+ *
26
+ * 将语言环境字符串解析为对应的 AreaCode 枚举值。
27
+ * 输入不区分大小写(如 "ZH_CN"、"zh_cn"、"zh_CN" 均解析为 AreaCode.zh_CN)。
28
+ *
29
+ * 字符串无法匹配时:
30
+ * - `forceArea` 省略或为 false → 返回 AreaCode.zh_CN(宽松默认值)
31
+ * - `forceArea` 为 true → 返回 AreaCode.unknown(严格模式)
32
+ *
33
+ * @param areaStr the locale string to parse; defaults to "zh_CN" if omitted / 要解析的语言环境字符串,省略时默认为 "zh_CN"
34
+ * @param forceArea when true, returns AreaCode.unknown for unrecognised strings / 为 true 时,无法识别的字符串返回 AreaCode.unknown
35
+ * @returns the matching AreaCode enum value / 对应的 AreaCode 枚举值
12
36
  *
13
- * @param areaStr the source string
14
- * @param forceArea a boolean value indicates whether needs to have a strict check for the source string. (That means if in strict mode and the string could not be converted, an unkonwn will be returned.)
15
- * @returns return the area code
37
+ * @example
38
+ * parseAreaString("zh_CN"); // AreaCode.zh_CN
39
+ * parseAreaString("en_US"); // AreaCode.en_US
40
+ * parseAreaString("invalid", true); // AreaCode.unknown
41
+ * parseAreaString("invalid"); // AreaCode.zh_CN
16
42
  */
17
43
  export declare function parseAreaString(areaStr?: string, forceArea?: boolean): AreaCode;
@@ -2,11 +2,43 @@
2
2
  import { ILog, IPerfRecorder } from "../types/Logs";
3
3
  declare function _startPerf(id?: string): IPerfRecorder;
4
4
  declare function _endPerf(recorder: IPerfRecorder, console?: boolean): number;
5
- /** Tianyu Log Instance */
5
+ /**
6
+ * The global Tianyu log instance.
7
+ * Provides leveled console logging with optional timestamp support.
8
+ *
9
+ * 全局 Tianyu 日志实例。
10
+ * 提供带可选时间戳的分级控制台日志功能。
11
+ */
6
12
  export declare const Log: ILog;
7
- /** Tianyu Performance Instance */
13
+ /**
14
+ * The global Tianyu performance tracking instance.
15
+ * Use startPerf / endPerf to measure elapsed time for any named operation.
16
+ *
17
+ * 全局 Tianyu 性能跟踪实例。
18
+ * 使用 startPerf / endPerf 测量任意命名操作的耗时。
19
+ *
20
+ * @example
21
+ * const rec = Performance.startPerf("db-query");
22
+ * // ... do work ...
23
+ * const ms = Performance.endPerf(rec, true); // logs and returns elapsed ms
24
+ */
8
25
  export declare const Performance: {
26
+ /**
27
+ * Start a performance recording session.
28
+ * 开始一次性能记录会话。
29
+ *
30
+ * @param id optional session name / 可选的会话名称
31
+ * @returns a recorder object holding the start timestamp / 包含开始时间戳的记录器对象
32
+ */
9
33
  startPerf: typeof _startPerf;
34
+ /**
35
+ * End a performance recording session and return elapsed milliseconds.
36
+ * 结束性能记录会话并返回经过的毫秒数。
37
+ *
38
+ * @param recorder the recorder returned by startPerf / startPerf 返回的记录器
39
+ * @param console whether to print the elapsed time to the console / 是否将耗时输出到控制台
40
+ * @returns elapsed time in milliseconds / 经过的毫秒数
41
+ */
10
42
  endPerf: typeof _endPerf;
11
43
  };
12
44
  export {};
@@ -1,2 +1,22 @@
1
1
  /**@format */
2
+ /**
3
+ * Convert a value of any type to a boolean.
4
+ * Conversion rules:
5
+ * - null / undefined → false
6
+ * - number: 0 → false, any other number → true
7
+ * - string: "" or "false" (case-insensitive) → false, any other non-empty string → true
8
+ * - boolean: returned as-is
9
+ * - any other type → true
10
+ *
11
+ * 将任意类型的值转换为布尔值。
12
+ * 转换规则:
13
+ * - null / undefined → false
14
+ * - number:0 → false,其他数值 → true
15
+ * - string:空字符串或 "false"(大小写不敏感)→ false,其他非空字符串 → true
16
+ * - boolean:直接返回原值
17
+ * - 其他类型 → true
18
+ *
19
+ * @param value the value to convert / 要转换的值
20
+ * @returns the boolean result / 转换后的布尔值
21
+ */
2
22
  export declare function getBoolean(value: any): boolean;
@@ -1,5 +1,16 @@
1
1
  /** @format */
2
2
  import { IComparable } from "../../../src/types/Types";
3
+ /**
4
+ * Base interface for aitianyu JSON-representable types.
5
+ * Extends IComparable and requires a toString() method.
6
+ *
7
+ * aitianyu 可 JSON 表示类型的基础接口。
8
+ * 继承 IComparable 并要求实现 toString() 方法。
9
+ */
3
10
  export interface ITianyuJSON extends IComparable {
11
+ /**
12
+ * Serialize this object to a JSON string.
13
+ * 将当前对象序列化为 JSON 字符串。
14
+ */
4
15
  toString(): string;
5
16
  }
@@ -1,5 +1,16 @@
1
1
  /** @format */
2
2
  import { IComparable } from "../../../src/types/Types";
3
+ /**
4
+ * Base interface for all aitianyu typed wrapper objects.
5
+ * Extends IComparable and requires a toString() method for serialization.
6
+ *
7
+ * 所有 aitianyu 类型包装对象的基础接口。
8
+ * 继承 IComparable 并要求实现 toString() 方法以支持序列化。
9
+ */
3
10
  export interface ITianyuType extends IComparable {
11
+ /**
12
+ * Convert this object to its string representation.
13
+ * 将当前对象转换为字符串表示形式。
14
+ */
4
15
  toString(): string;
5
16
  }
@@ -1,11 +1,22 @@
1
1
  /**@format */
2
- /** Array type related tools */
2
+ /**
3
+ * Array utility class providing merge and deduplication helpers.
4
+ * 数组工具类,提供合并与去重帮助方法。
5
+ */
3
6
  export declare class ArrayHelper {
4
7
  /**
5
- * To merge multiple arrays into a new array and remove duplicated elements.
8
+ * Merge multiple arrays (or individual values) into a single new array,
9
+ * removing duplicate elements. Non-array arguments are treated as single-item arrays.
6
10
  *
7
- * @param {any[]} array arrays
8
- * @returns return a new array
11
+ * 将多个数组(或单个值)合并为一个新数组,并移除重复元素。
12
+ * 非数组参数被视为单元素数组处理。
13
+ *
14
+ * @param array any number of arrays or individual values / 任意数量的数组或单个值
15
+ * @returns a new deduplicated array / 去重后的新数组
16
+ *
17
+ * @example
18
+ * ArrayHelper.merge([1, 2], [2, 3], 4);
19
+ * // => [1, 2, 3, 4]
9
20
  */
10
21
  static merge(...array: any[]): any[];
11
22
  }
@@ -1,13 +1,17 @@
1
1
  /** @format */
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- /** Bytes Object type */
4
+ /**
5
+ * Byte buffer utility class.
6
+ * 字节缓冲区工具类。
7
+ */
5
8
  export declare class Bytes {
6
9
  /**
7
- * Get a bytes buffer filled with random data
10
+ * Generate a Buffer of the specified size filled with cryptographically random bytes.
11
+ * 生成指定大小、由密码学安全随机字节填充的 Buffer。
8
12
  *
9
- * @param size the length of bytes buffer
10
- * @returns buffer
13
+ * @param size the number of random bytes to generate / 要生成的随机字节数
14
+ * @returns a Buffer containing random data / 包含随机数据的 Buffer
11
15
  */
12
16
  static random(size: number): Buffer;
13
17
  }