@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
@@ -1,22 +1,50 @@
1
1
  /**@format */
2
2
  import { ObjectDiffMap } from "../../types/Object";
3
- /** Object Calculation Manager of Tianyu to provide data changes delta calculation and merge */
3
+ /**
4
+ * Object diff calculation and merge manager.
5
+ * Provides two static operations:
6
+ * 1. calculateDiff — compute the field-level delta between two object snapshots.
7
+ * 2. mergeDiff — apply one or more diff maps to an object to advance its state.
8
+ *
9
+ * 对象差异计算与合并管理器。
10
+ * 提供两个静态操作:
11
+ * 1. calculateDiff — 计算两个对象快照之间的字段级差异。
12
+ * 2. mergeDiff — 将一个或多个差异映射表应用到对象以推进其状态。
13
+ */
4
14
  export declare class ObjectCalculater {
5
15
  /**
6
- * Compare two objects and get the delta changes between the two objects
16
+ * Compute the field-level differences between two object snapshots.
17
+ * The result is an ObjectDiffMap keyed by the path of each changed field.
7
18
  *
8
- * @param previous the previous object
9
- * @param newest the newest object
10
- * @returns return the defferents map
19
+ * 计算两个对象快照之间的字段级差异。
20
+ * 结果是以每个变更字段路径为键的 ObjectDiffMap。
21
+ *
22
+ * @param previous the previous (old) state / 之前(旧)状态的对象
23
+ * @param newest the next (new) state / 之后(新)状态的对象
24
+ * @returns a map of all field differences / 所有字段差异的映射表
11
25
  */
12
26
  static calculateDiff(previous: any, newest: any): ObjectDiffMap;
13
27
  /**
14
- * Merge the object value status from one to another one following with the object different maps
28
+ * Apply an ordered sequence of diff maps to a value, producing the final merged state.
29
+ * Each diff map is applied in array order (earlier diffs are applied first).
30
+ *
31
+ * In strict mode, every merge step is validated:
32
+ * - Root-level diffs must not coexist with other diffs in the same map.
33
+ * - The current state must match the `old` value recorded in the diff entry.
34
+ * - Added fields must not already exist; deleted fields must still exist.
35
+ *
36
+ * 将有序的差异映射表序列应用到值上,生成最终合并状态。
37
+ * 每个差异映射表按数组顺序依次应用(先应用靠前的)。
38
+ *
39
+ * 在严格模式下,每步合并都会进行校验:
40
+ * - 根级差异不能与同一映射表中的其他差异共存。
41
+ * - 当前状态必须与差异条目中记录的 `old` 值匹配。
42
+ * - 新增字段不能已经存在;删除字段必须仍然存在。
15
43
  *
16
- * @param value the raw value(status)
17
- * @param diffs the value changed status map array, contains multiply status maps and the status merge will be one by one.
18
- * @param strict a boolean value used to whether the program needs a strict status check to avoid some data errors
19
- * @returns return a new value status
44
+ * @param value the base value to apply diffs onto / 要应用差异的基础值
45
+ * @param diffs an ordered array of diff maps to apply / 要依次应用的差异映射表数组
46
+ * @param strict when true, validates pre/post state on every change; defaults to false / true 时对每次变更校验前后状态,默认为 false
47
+ * @returns the resulting value after all diffs have been applied / 应用所有差异后的最终值
20
48
  */
21
49
  static mergeDiff(value: any, diffs: ObjectDiffMap[], strict?: boolean): any;
22
50
  }
@@ -1,11 +1,20 @@
1
1
  /** @format */
2
- /** DataView Object Type */
2
+ /**
3
+ * DataView utility class for creating a globalThis.DataView from typed array buffers.
4
+ * 用于从类型化数组缓冲区创建 globalThis.DataView 的工具类。
5
+ */
3
6
  export declare class DataView {
4
7
  /**
5
- * Create a new node:DataView from given data buffer
8
+ * Create a globalThis.DataView wrapping the given buffer.
9
+ * Supports ArrayBuffer, Int8Array, Uint8Array, and Uint8ClampedArray as input.
10
+ * Throws an Error for unsupported input types.
6
11
  *
7
- * @param data source data buffer
8
- * @returns return node:DataView type equals to given data buffer
12
+ * 创建一个包装给定缓冲区的 globalThis.DataView。
13
+ * 支持 ArrayBuffer、Int8Array、Uint8Array Uint8ClampedArray 作为输入。
14
+ * 不支持的输入类型将抛出 Error。
15
+ *
16
+ * @param data the source data buffer / 源数据缓冲区
17
+ * @returns a DataView over the given buffer / 对给定缓冲区的 DataView 视图
9
18
  */
10
19
  static parse(data: ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray): globalThis.DataView;
11
20
  }
@@ -1,71 +1,92 @@
1
1
  /** @format */
2
- /** Integer Object Type */
2
+ /**
3
+ * Integer utility class providing random number generation,
4
+ * byte conversion, and safe bitwise operations.
5
+ *
6
+ * 整数工具类,提供随机数生成、字节转换及安全位运算操作。
7
+ */
3
8
  export declare class Integer {
4
9
  /**
5
- * Get a random integer between min value and max value.
6
- * min value should greater than 0, max value should less than 2^48-1 (281474976710655)
10
+ * Generate a cryptographically random integer in the range [min, max).
11
+ * min is clamped to 0; max defaults to 2^48-1 (281474976710655).
7
12
  *
8
- * @param min the min value (0 will be applied when not given)
9
- * @param max the max value (281474976710655 will be applied when not given)
10
- * @returns return the random value
13
+ * [min, max) 范围内生成密码学安全的随机整数。
14
+ * min 最小为 0;max 默认为 2^48-1(281474976710655)。
15
+ *
16
+ * @param min lower bound (inclusive), defaults to 0 / 下界(含),默认为 0
17
+ * @param max upper bound (exclusive), defaults to 281474976710655 / 上界(不含),默认为 281474976710655
18
+ * @returns the random integer / 随机整数
11
19
  */
12
20
  static random(min?: number, max?: number): number;
13
21
  /**
14
- * convert source number to be a 8-byte array
22
+ * Convert a number to an 8-byte (big-endian) number array.
23
+ * 将数值转换为 8 字节(大端序)数字数组。
15
24
  *
16
- * @param srcValue source value
17
- * @returns return a 8-byte array
25
+ * @param srcValue the source number / 源数值
26
+ * @returns an 8-element array of byte values / 包含 8 个字节值的数组
18
27
  */
19
28
  static toBytes(srcValue: number): number[];
20
29
  /**
21
- * number left shift
22
- * times will be calculated to get the end 6-bit at the beginning to avoid over-flow
30
+ * Left-shift `value` by `times` bits.
31
+ * Only the lowest 6 bits of `times` are used to prevent overflow.
32
+ *
33
+ * 将 `value` 左移 `times` 位。
34
+ * 仅使用 `times` 的低 6 位以防止溢出。
23
35
  *
24
- * @param value source value
25
- * @param times left shift steps
26
- * @returns return result value
36
+ * @param value source value / 源数值
37
+ * @param times number of bits to shift / 移位位数
38
+ * @returns shifted result / 移位结果
27
39
  */
28
40
  static left(value: number, times: number): number;
29
41
  /**
30
- * number right shift
31
- * times will be calculated to get the end 6-bit at the beginning to avoid over-flow
42
+ * Signed right-shift `value` by `times` bits.
43
+ * Only the lowest 6 bits of `times` are used to prevent overflow.
32
44
  *
33
- * @param value source value
34
- * @param times right shift steps
35
- * @returns return result value
45
+ * `value` 进行有符号右移 `times` 位。
46
+ * 仅使用 `times` 的低 6 位以防止溢出。
47
+ *
48
+ * @param value source value / 源数值
49
+ * @param times number of bits to shift / 移位位数
50
+ * @returns shifted result / 移位结果
36
51
  */
37
52
  static right(value: number, times: number): number;
38
53
  /**
39
- * number unsigned right shift
40
- * times will be calculated to get the end 6-bit at the beginning to avoid over-flow
54
+ * Unsigned right-shift `value` by `times` bits.
55
+ * Only the lowest 6 bits of `times` are used to prevent overflow.
56
+ *
57
+ * 对 `value` 进行无符号右移 `times` 位。
58
+ * 仅使用 `times` 的低 6 位以防止溢出。
41
59
  *
42
- * @param value source value
43
- * @param times right shift steps
44
- * @returns return result value
60
+ * @param value source value / 源数值
61
+ * @param times number of bits to shift / 移位位数
62
+ * @returns shifted result / 移位结果
45
63
  */
46
64
  static rightUnsigned(value: number, times: number): number;
47
65
  /**
48
- * or
66
+ * Bitwise OR of value1 and one or more additional values.
67
+ * 对 value1 与一个或多个附加值进行按位或运算。
49
68
  *
50
- * @param value1 the first value
51
- * @param values the following values array
52
- * @returns return calculated value
69
+ * @param value1 the first operand / 第一个操作数
70
+ * @param values additional operands / 附加操作数
71
+ * @returns the bitwise OR result / 按位或结果
53
72
  */
54
73
  static or(value1: number, ...values: number[]): number;
55
74
  /**
56
- * and
75
+ * Bitwise AND of value1 and one or more additional values.
76
+ * 对 value1 与一个或多个附加值进行按位与运算。
57
77
  *
58
- * @param value1 the first value
59
- * @param values the following values array
60
- * @returns return calculated value
78
+ * @param value1 the first operand / 第一个操作数
79
+ * @param values additional operands / 附加操作数
80
+ * @returns the bitwise AND result / 按位与结果
61
81
  */
62
82
  static and(value1: number, ...values: number[]): number;
63
83
  /**
64
- * xor
84
+ * Bitwise XOR of value1 and value2.
85
+ * 对 value1 和 value2 进行按位异或运算。
65
86
  *
66
- * @param value1 the first value
67
- * @param value2 the second value
68
- * @returns return calculated value
87
+ * @param value1 the first operand / 第一个操作数
88
+ * @param value2 the second operand / 第二个操作数
89
+ * @returns the XOR result / 异或结果
69
90
  */
70
91
  static xor(value1: number, value2: number): number;
71
92
  }
@@ -1,22 +1,34 @@
1
1
  /** @format */
2
- /** Json Lib */
2
+ /**
3
+ * JSON utility class providing safe and unsafe JSON parse helpers.
4
+ * JSON 工具类,提供安全与非安全的 JSON 解析帮助方法。
5
+ */
3
6
  export declare class Json {
4
7
  /**
5
- * @deprecated
8
+ * @deprecated Use parseSafe instead.
6
9
  *
7
- * convert a string to be a javascript object.
8
- * This is an unsafe function to convert a string to be object. suggest to use parseSafe to convert string to object.
10
+ * Parse a JSON string into a JavaScript object.
11
+ * This is an unsafe operation it throws a SyntaxError if the string is invalid.
12
+ * Prefer parseSafe for production use.
9
13
  *
10
- * @param src source string
11
- * @returns target js-object
14
+ * JSON 字符串解析为 JavaScript 对象。
15
+ * 这是一个不安全的操作——若字符串无效则抛出 SyntaxError。
16
+ * 生产环境建议使用 parseSafe。
17
+ *
18
+ * @param src the JSON source string / JSON 源字符串
19
+ * @returns the parsed JavaScript object / 解析后的 JavaScript 对象
12
20
  */
13
21
  static parse(src: string): any;
14
22
  /**
15
- * convert a string to be a javascript object safty
23
+ * Parse a JSON string into a JavaScript object safely.
24
+ * Returns the specified fallback value (default: null) if parsing fails.
25
+ *
26
+ * 安全地将 JSON 字符串解析为 JavaScript 对象。
27
+ * 解析失败时返回指定的回退值(默认为 null)。
16
28
  *
17
- * @param src source string
18
- * @param failed value returned when converted failed, default is null
19
- * @returns target js-object
29
+ * @param src the JSON source string / JSON 源字符串
30
+ * @param failed the value to return on parse failure, defaults to null / 解析失败时的返回值,默认为 null
31
+ * @returns the parsed object, or the fallback value on failure / 解析后的对象,失败时返回回退值
20
32
  */
21
33
  static parseSafe(src: string, failed?: any): any | null;
22
34
  }
@@ -1,36 +1,60 @@
1
1
  /**@format */
2
- /** Object Helper of Tianyu to provide data type checking, objects comparing, validation, data clone and other functions */
2
+ /**
3
+ * Object utility class providing data type checking, deep cloning,
4
+ * serialization validation, and multi-object comparison.
5
+ *
6
+ * 对象工具类,提供数据类型检测、深度克隆、序列化校验和多对象比较功能。
7
+ */
3
8
  export declare class ObjectHelper {
4
9
  /**
5
- * check whether the specified value does extend from nodejs native type
10
+ * Check whether the given value is a JavaScript primitive type
11
+ * (boolean, string, number, symbol, null, or undefined).
6
12
  *
7
- * @param {any} value supported value type of tianyu store
8
- * @returns {boolean} return true if the value is based on type number, string, boolean, function, otherwise false
13
+ * 检查给定值是否为 JavaScript 原始类型
14
+ * boolean、string、number、symbol、null undefined)。
15
+ *
16
+ * @param value the value to inspect / 要检查的值
17
+ * @returns true if the value is a primitive type, false for objects and arrays
18
+ * 原始类型返回 true,对象和数组返回 false
9
19
  */
10
20
  static isSimpleDataType(value: any): boolean;
11
21
  /**
12
- * get a deep copy from source
22
+ * Create a deep copy of the given value.
23
+ * Arrays and plain objects are recursively cloned.
24
+ * Throws ObjectCloneFunctionNotSupportException if the source contains a function.
25
+ *
26
+ * 创建给定值的深度副本。
27
+ * 数组和普通对象将递归克隆。
28
+ * 若源对象包含函数值,则抛出 ObjectCloneFunctionNotSupportException。
13
29
  *
14
- * @param {any} sources the specified source value
15
- * @returns {any} return a new value that is independent from sources
30
+ * @param source the value to clone / 要克隆的值
31
+ * @returns a new deep-copied value independent from the source / 与源对象独立的深度副本
16
32
  */
17
33
  static clone(source: any): any;
18
34
  private static _clone;
19
35
  private static _cloneArray;
20
36
  private static _cloneRecordType;
21
37
  /**
22
- * Check the object whether can be stringified
38
+ * Verify that the given value can be safely passed through JSON.stringify.
39
+ * Returns false for function types or objects containing function-valued properties.
23
40
  *
24
- * @param obj be checked object
25
- * @returns return true is valid, otherwise false
41
+ * 验证给定值是否可安全通过 JSON.stringify 序列化。
42
+ * 函数类型或包含函数属性的对象返回 false
43
+ *
44
+ * @param obj the value to validate / 要校验的值
45
+ * @returns true if the value is JSON-serializable / 可 JSON 序列化时返回 true
26
46
  */
27
47
  static validateSerializable(obj: any): boolean;
28
48
  /**
29
- * Compare two or more objects are the same or different
49
+ * Compare two or more values for deep equality.
50
+ * If fewer than two arguments are provided, "same" is returned.
51
+ *
52
+ * 对两个或多个值进行深度相等性比较。
53
+ * 若传入参数少于两个,则返回 "same"。
30
54
  *
31
- * @param objs the objects which need to be compared
32
- * @returns same - if all the objects are same, different - if at least one object is not same to other objects
33
- * @description if there are only one parameter or no parameter is provided, same result will be returned
55
+ * @param objs the values to compare / 要比较的值
56
+ * @returns "same" if all values are deeply equal, "different" otherwise
57
+ * 所有值深度相等时返回 "same",否则返回 "different"
34
58
  */
35
59
  static compareObjects(...objs: any): "same" | "different";
36
60
  private static _compareSimpleType;
@@ -1,21 +1,48 @@
1
1
  /**@format */
2
+ /**
3
+ * String utility class providing formatting and safe serialization helpers.
4
+ * 字符串工具类,提供格式化和安全序列化帮助方法。
5
+ */
2
6
  export declare class StringHelper {
7
+ /**
8
+ * Format a string by replacing positional placeholders `{N}` with the corresponding argument.
9
+ * Works similarly to C#'s String.Format.
10
+ *
11
+ * 通过将位置占位符 `{N}` 替换为对应参数来格式化字符串。
12
+ * 用法类似于 C# 的 String.Format。
13
+ *
14
+ * @param source the format template string containing `{0}`, `{1}`, … placeholders / 包含 `{0}`、`{1}` 等占位符的格式模板字符串
15
+ * @param args a single argument or an array of arguments / 单个参数或参数数组
16
+ * @returns the formatted string / 格式化后的字符串
17
+ *
18
+ * @example
19
+ * StringHelper.format("Hello, {0}! You have {1} messages.", "Alice", 5);
20
+ * // => "Hello, Alice! You have 5 messages."
21
+ */
3
22
  static format(source: string, args?: (string | number)[] | string): string;
4
23
  /**
5
- * @deprecated
24
+ * @deprecated Use stringifySafe instead.
25
+ *
26
+ * Convert a value to a string. Throws an Error if the value is a function type.
27
+ * For safer usage, prefer stringifySafe which returns "" on failure.
6
28
  *
7
- * convert an object to be a string.
8
- * This is an unsafe function to convert an object to be string. suggest to use stringifySafe to convert object to string.
29
+ * 将值转换为字符串。若值为函数类型则抛出 Error。
30
+ * 建议使用更安全的 stringifySafe,失败时返回 ""。
9
31
  *
10
- * @param src source object
11
- * @returns target string
32
+ * @param data the value to convert / 要转换的值
33
+ * @returns the string representation / 字符串表示
12
34
  */
13
35
  static stringify(data: any): string;
14
36
  /**
15
- * convert an object to be a string safty. empty string will be return when error occurs in converting
37
+ * Convert a value to a string safely.
38
+ * Returns an empty string if any error occurs during conversion
39
+ * (e.g. circular references or function types).
40
+ *
41
+ * 安全地将值转换为字符串。
42
+ * 若转换过程中发生任何错误(如循环引用或函数类型),则返回空字符串。
16
43
  *
17
- * @param src source object
18
- * @returns target string
44
+ * @param data the value to convert / 要转换的值
45
+ * @returns the string representation, or "" on failure / 字符串表示,失败时返回 ""
19
46
  */
20
47
  static stringifySafe(data: any): string;
21
48
  }
@@ -1,31 +1,75 @@
1
1
  /**@format */
2
+ /**
3
+ * @aitianyu.cn/types — Public API entry point
4
+ *
5
+ * This file re-exports every public symbol from the library.
6
+ * Import from this package directly rather than from sub-paths.
7
+ *
8
+ * @aitianyu.cn/types — 公共 API 入口
9
+ *
10
+ * 本文件重新导出库中所有公共符号。
11
+ * 请直接从本包导入,而非从子路径导入。
12
+ *
13
+ * @example
14
+ * import { guid, Log, StringHelper, TOTP } from "@aitianyu.cn/types";
15
+ */
16
+ /** International area code enum. / 国际区域码枚举。 */
2
17
  export { AreaCode } from "./types/AreaCode";
18
+ /** Base exception class for all custom errors. / 所有自定义异常的基类。 */
3
19
  export { Exception } from "./types/Exception";
20
+ /** Log level enum and log/performance recorder interfaces. / 日志级别枚举及日志/性能记录器接口。 */
4
21
  export { LogLevel, type ILog, type IPerfRecorder } from "./types/Logs";
22
+ /** Object diff info interface and diff map type. / 对象差异信息接口和差异映射类型。 */
5
23
  export { type IObjectDiffInfo, type ObjectDiffMap } from "./types/Object";
24
+ /** Abstract path base class. / 抽象路径基类。 */
6
25
  export { PathBase } from "./types/PathBase";
26
+ /** Encryption option enum and cipher interface. / 加密选项枚举和密码接口。 */
7
27
  export { EncryptOption, type ICipher } from "./types/Security";
28
+ /** Generic comparable-key map. / 支持可比较键的泛型映射表。 */
8
29
  export { TMap } from "./types/TMap";
30
+ /** Common generic types and interfaces. / 通用泛型类型与接口。 */
9
31
  export { type MapOfBoolean, type MapOfStrings, type MapOfString, type MapOfType, type CallbackAction, type CallbackActionT, type IComparable, type KeyValuePair, } from "./types/Types";
32
+ /** Path-related exception classes. / 路径相关异常类。 */
10
33
  export { PathProcessorSourceLostException, PathDirectoryValidationFailException, PathDirAndFileConvertInvaild, } from "./coding/Error";
34
+ /** Path type and Path class. / 路径类型及 Path 类。 */
11
35
  export { type PathTargetType, Path } from "./coding/Path";
36
+ /** Core exception classes for argument and object operations. / 参数和对象操作的核心异常类。 */
12
37
  export { ArgumentNullOrEmptyException, ObjectCloneFunctionNotSupportException, ObjectMergeStatusCheckFailedException, ObjectDiffApplyInvalidStatusException, ObjectDiffMergeFailedException, } from "./core/Errors";
38
+ /** Area code ↔ string conversion helpers. / 区域码与字符串的转换帮助函数。 */
13
39
  export { parseAreaCode, parseAreaString } from "./core/Language";
40
+ /** Global log instance and performance tracker. / 全局日志实例和性能跟踪器。 */
14
41
  export { Log, Performance } from "./core/Log";
42
+ /** Type conversion helpers. / 类型转换帮助函数。 */
15
43
  export { getBoolean } from "./core/TypeConvertion";
44
+ /** Runtime environment detection. / 运行时环境检测。 */
16
45
  export { Environment } from "./core/Environment";
46
+ /** Object diff calculation and merge. / 对象差异计算与合并。 */
17
47
  export { ObjectCalculater } from "./core/object/Calculater";
48
+ /** Deep clone, compare, and serialization validation. / 深度克隆、比较和序列化校验。 */
18
49
  export { ObjectHelper } from "./core/object/ObjectHelper";
50
+ /** Array merge and deduplication. / 数组合并与去重。 */
19
51
  export { ArrayHelper } from "./core/object/ArrayHelper";
52
+ /** String formatting and safe serialization. / 字符串格式化和安全序列化。 */
20
53
  export { StringHelper } from "./core/object/StringHelper";
54
+ /** Random byte buffer generation. / 随机字节缓冲区生成。 */
21
55
  export { Bytes } from "./core/object/Bytes";
56
+ /** Binary DataView parsing helper. / 二进制 DataView 解析帮助工具。 */
22
57
  export { DataView } from "./core/object/DataView";
58
+ /** Bitwise operations and random integer generation. / 位运算和随机整数生成。 */
23
59
  export { Integer } from "./core/object/Integer";
60
+ /** Safe JSON parsing helpers. / 安全 JSON 解析帮助工具。 */
24
61
  export { Json } from "./core/object/Json";
62
+ /** Base32 encoding/decoding (RFC3548, RFC4648, RFC4648-HEX, Crockford). / Base32 编解码。 */
25
63
  export { Base32 } from "./security/Base32";
64
+ /** UUID v4 generation. / UUID v4 生成。 */
26
65
  export { guid } from "./security/Guid";
66
+ /** 32-bit string hash code generation. / 32 位字符串哈希码生成。 */
27
67
  export { hash } from "./security/Hash";
68
+ /** Async QR code image generation (base64 data URL). / 异步二维码图片生成(base64 data URL)。 */
28
69
  export { QRCode } from "./security/QRCode";
70
+ /** RSA key-pair generation and directional encryption/decryption. / RSA 密钥对生成及方向性加密/解密。 */
29
71
  export { RSA } from "./security/RSA";
72
+ /** SHA-256 / SHA-512 hashing for data and streams. / 数据和流的 SHA-256 / SHA-512 哈希计算。 */
30
73
  export { SHA } from "./security/SHA";
74
+ /** Time-based One-Time Password generation (RFC 6238). / 基于时间的一次性密码生成(RFC 6238)。 */
31
75
  export { TOTP } from "./security/TOTP";
@@ -1,40 +1,53 @@
1
1
  /** @format */
2
2
  /**
3
- * Base32 Encoding Type
3
+ * Base32 encoding format type.
4
+ * Base32 编码格式类型。
4
5
  *
5
- * @field RFC3548
6
- * @field RFC4648
7
- * @field RFC4648-HEX
8
- * @field Crockford
6
+ * - RFC3548 / RFC4648: Standard alphabet A–Z + 2–7 with "=" padding.
7
+ * - RFC4648-HEX: Extended hex alphabet 0–9 + A–V.
8
+ * - Crockford: Human-friendly alphabet; treats O→0, I/L→1; no padding.
9
+ *
10
+ * - RFC3548 / RFC4648:标准字母表 A–Z + 2–7,使用 "=" 填充。
11
+ * - RFC4648-HEX:扩展十六进制字母表 0–9 + A–V。
12
+ * - Crockford:人类友好字母表;将 O→0、I/L→1;无填充。
9
13
  */
10
14
  export type EncodingType = "RFC3548" | "RFC4648" | "RFC4648-HEX" | "Crockford";
11
- /** Base32 Encoding Lib */
15
+ /**
16
+ * Base32 encoding/decoding utility class.
17
+ * Supports RFC3548, RFC4648, RFC4648-HEX, and Crockford encoding formats.
18
+ *
19
+ * Base32 编解码工具类。
20
+ * 支持 RFC3548、RFC4648、RFC4648-HEX 和 Crockford 编码格式。
21
+ */
12
22
  export declare class Base32 {
13
23
  private static RFC4648_CHS;
14
24
  private static RFC4648_HEX_CHS;
15
25
  private static CROCKFORD_CHS;
16
26
  /**
17
- * To encode the buffer to be a Base32 encoded string
27
+ * Encode a binary buffer to a Base32 string using the specified encoding format.
28
+ * 使用指定的编码格式将二进制缓冲区编码为 Base32 字符串。
18
29
  *
19
- * @param data input source buffer
20
- * @param encoding encoding type
21
- * @returns return the encoded string
30
+ * @param data the input buffer to encode / 要编码的输入缓冲区
31
+ * @param encoding the Base32 encoding format to use / 要使用的 Base32 编码格式
32
+ * @returns the Base32-encoded string / Base32 编码后的字符串
22
33
  */
23
34
  static encode(data: ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray, encoding: EncodingType): string;
24
35
  /**
25
- * Decode the input string to be an array buffer
36
+ * Decode a Base32 string back to an ArrayBuffer using the specified encoding format.
37
+ * 使用指定的编码格式将 Base32 字符串解码还原为 ArrayBuffer。
26
38
  *
27
- * @param input source string
28
- * @param encoding encoding type
29
- * @returns return the target array buffer
39
+ * @param input the Base32-encoded source string / Base32 编码的源字符串
40
+ * @param encoding the encoding format used to encode the string / 字符串编码时使用的格式
41
+ * @returns the decoded ArrayBuffer / 解码后的 ArrayBuffer
30
42
  */
31
43
  static decode(input: string, encoding: EncodingType): ArrayBuffer;
32
44
  /**
33
- * Get a random string which is encoded by given encoding type
45
+ * Generate a random Base32-encoded string from cryptographically random bytes.
46
+ * 从密码学安全随机字节生成随机 Base32 编码字符串。
34
47
  *
35
- * @param size random bytes size
36
- * @param encoding encoding type
37
- * @returns return encoded random string
48
+ * @param size the number of random bytes to generate before encoding / 编码前生成的随机字节数
49
+ * @param encoding the encoding format to use, defaults to RFC4648 / 要使用的编码格式,默认为 RFC4648
50
+ * @returns the random Base32-encoded string / 随机 Base32 编码字符串
38
51
  */
39
52
  static random(size: number, encoding?: EncodingType): string;
40
53
  private static getAlphabet;
@@ -1,4 +1,22 @@
1
1
  /**@format */
2
+ /** Output format for the generated GUID. / 生成 GUID 的输出格式。 */
2
3
  export type GuidType = "none" | "default";
3
- /** Generate a Guid value string */
4
+ /**
5
+ * Generate a UUID v4 string.
6
+ * Uses a combination of the current time and high-resolution performance counter
7
+ * as a random seed to maximise uniqueness.
8
+ *
9
+ * 生成 UUID v4 字符串。
10
+ * 使用当前时间与高精度性能计数器的组合作为随机种子,以最大化唯一性。
11
+ *
12
+ * @param type the output format:
13
+ * - "default" (default) — standard hyphenated form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
14
+ * - "none" — compact form without hyphens
15
+ *
16
+ * 输出格式:
17
+ * - "default"(默认)—— 标准连字符形式 "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
18
+ * - "none" —— 无连字符的紧凑形式
19
+ *
20
+ * @returns the UUID string / UUID 字符串
21
+ */
4
22
  export declare function guid(type?: GuidType): string;
@@ -1,3 +1,12 @@
1
1
  /**@format */
2
- /** Generate a hash code number of the string */
2
+ /**
3
+ * Generate a 32-bit integer hash code from the given string.
4
+ * Uses a djb2-style rolling hash algorithm over the character codes.
5
+ *
6
+ * 从给定字符串生成 32 位整数哈希码。
7
+ * 使用基于字符码的 djb2 风格滚动哈希算法。
8
+ *
9
+ * @param source the input string / 输入字符串
10
+ * @returns a 32-bit integer hash code / 32 位整数哈希码
11
+ */
3
12
  export declare function hash(source: string): number;
@@ -1,11 +1,23 @@
1
1
  /** @format */
2
- /** QR code Lib */
2
+ /**
3
+ * QR code generation utility class.
4
+ * Wraps the `qrcode` library to provide an async base64 data-URL API.
5
+ *
6
+ * 二维码生成工具类。
7
+ * 封装 `qrcode` 库,提供异步 base64 data-URL 接口。
8
+ */
3
9
  export declare class QRCode {
4
10
  /**
5
- * Async getting a base64 URL of given text
11
+ * Asynchronously generate a base64-encoded PNG data URL for the given text.
12
+ * The returned data URL can be used directly as an `<img src="...">` attribute.
13
+ * Returns an empty string if QR code generation fails.
6
14
  *
7
- * @param text source text
8
- * @returns return base64 URL string
15
+ * 异步为给定文本生成 base64 编码的 PNG data URL。
16
+ * 返回的 data URL 可直接用作 `<img src="...">` 属性值。
17
+ * 若二维码生成失败则返回空字符串。
18
+ *
19
+ * @param text the text or URL to encode into the QR code / 要编码为二维码的文本或 URL
20
+ * @returns a Promise that resolves to the base64 data URL, or "" on error / 解析为 base64 data URL 的 Promise,出错时为 ""
9
21
  */
10
22
  static getURL(text: string): Promise<string>;
11
23
  }