nhanh-pure-function 4.6.0 → 4.6.2

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.
@@ -108,4 +108,12 @@ export declare function _Format_MillisecondToReadable(ms: number, maxUnit?: Unit
108
108
  * @throws 当size小于1时抛出错误
109
109
  */
110
110
  export declare function _Format_ChunkArray<T>(arr: T[], size: number): T[][];
111
+ /**
112
+ * 截断字符串,超出最大长度时追加后缀
113
+ * @param str 原始字符串
114
+ * @param max 最大长度
115
+ * @param suffix 超出时追加的后缀,默认为 "..."
116
+ * @returns 截断后的字符串
117
+ */
118
+ export declare function _Format_Truncate(str: string, max: number, suffix?: string): string;
111
119
  export {};
@@ -37,12 +37,3 @@ export type _Type_DeepPartial<T> = {
37
37
  export type _Type_Mutable<T> = {
38
38
  -readonly [P in keyof T]: T[P];
39
39
  };
40
- /**
41
- * 递归地将类型中的所有只读(readonly)属性转换为可写(writable)属性
42
- * @template T - 要处理的基础类型
43
- * @description 与TypeScript内置的Writable不同,DeepWritable会对嵌套对象进行递归处理,
44
- * 使所有层级的属性都变为可写。适用于需要修改对象属性的场景,但需要确保对象不会被其他地方引用。
45
- */
46
- export type _Type_DeepWritable<T> = {
47
- -readonly [P in keyof T]: _Type_DeepWritable<T[P]>;
48
- };
@@ -1,4 +1,3 @@
1
- import { _Type_DeepWritable } from '../Types';
2
1
  export * from './modules';
3
2
  /**
4
3
  * 寻找空闲时机执行传入方法
@@ -74,7 +73,7 @@ export declare function _Utility_RotateList<T>(list: T[]): T[][];
74
73
  * @param {any} val - 需要克隆的值
75
74
  * @returns {any} - 克隆后的值
76
75
  */
77
- export declare function _Utility_Clone<T>(val: T): _Type_DeepWritable<T>;
76
+ export declare function _Utility_Clone<T>(val: T): T;
78
77
  /**
79
78
  * 函数装饰器:精准测量并记录目标函数的执行耗时(单位:毫秒)
80
79
  *
@@ -1,3 +1,13 @@
1
+ /**
2
+ * RGBA 颜色分量对象。
3
+ * r/g/b 范围 0-255,a 范围 0-1
4
+ */
5
+ export interface _Utility_RGBA {
6
+ r: number;
7
+ g: number;
8
+ b: number;
9
+ a: number;
10
+ }
1
11
  /**
2
12
  * 颜色转换工具。
3
13
  * 支持输入:hex/rgb/hsl/hsv,统一解析后输出指定格式。
@@ -92,14 +102,20 @@ export declare class _Utility_ColorConverter {
92
102
  a: number;
93
103
  };
94
104
  /**
95
- * 判断两个颜色是否在允许的色差范围内(基于 RGB 欧几里得距离)。
96
- * @param colorA 第一个颜色字符串
97
- * @param colorB 第二个颜色字符串
98
- * @param threshold 允许的最大色差值,范围约 0(完全相同)到 442(黑白最大距离),含 alpha 时上限约 510
99
- * @param includeAlpha 是否将 alpha 差值纳入计算,默认 true;启用时 alpha 差值会缩放到 0-255 参与距离
105
+ * 将颜色输入统一解析为 RGBA 对象。
106
+ * 字符串走 parseColor,已是对象则直接返回。
107
+ */
108
+ private static resolveColorInput;
109
+ /**
110
+ * 判断两个颜色是否在允许的色差范围内(基于 RGBA 欧几里得距离)。
111
+ * 颜色参数支持任意颜色字符串或 { r, g, b, a } 对象。
112
+ * @param colorA 第一个颜色(字符串或 RGBA 对象)
113
+ * @param colorB 第二个颜色(字符串或 RGBA 对象)
114
+ * @param threshold 允许的最大色差值,范围约 0(完全相同)到 510(含 alpha 最大距离)
115
+ * @param includeAlpha 是否将 alpha 差值纳入计算,默认 true
100
116
  * @returns true 表示在允许色差内
101
117
  */
102
- static isWithinColorDifference(colorA: string, colorB: string, threshold: number, includeAlpha?: boolean): boolean;
118
+ static isWithinColorDifference(colorA: string | _Utility_RGBA, colorB: string | _Utility_RGBA, threshold: number, includeAlpha?: boolean): boolean;
103
119
  /**
104
120
  * 混合两个颜色(在 RGBA 空间线性插值)。
105
121
  * @param colorA 起始颜色