nhanh-pure-function 3.0.6-beta.1 → 3.0.6-beta.10

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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 ADMINnhanh
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ADMINnhanh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
- # nhanh-pure-function
2
-
3
- 纯函数工具库,提供了一些常用的纯函数工具,帮助您在 JavaScript/TypeScript 项目中更高效地处理数据。
4
-
5
- ## 安装
6
-
7
- 您可以通过 npm 安装该库:
8
-
9
- ```bash
10
- npm install nhanh-pure-function
11
- ```
12
-
13
- ## 功能介绍
14
-
15
- `nhanh-pure-function` 库旨在提供一系列纯函数,这些函数在处理数据时不会产生副作用,确保函数的输入和输出之间的映射关系是确定的。这使得代码更易于测试、维护和复用。
16
-
17
- ## 许可证
18
-
1
+ # nhanh-pure-function
2
+
3
+ 纯函数工具库,提供了一些常用的纯函数工具,帮助您在 JavaScript/TypeScript 项目中更高效地处理数据。
4
+
5
+ ## 安装
6
+
7
+ 您可以通过 npm 安装该库:
8
+
9
+ ```bash
10
+ npm install nhanh-pure-function
11
+ ```
12
+
13
+ ## 功能介绍
14
+
15
+ `nhanh-pure-function` 库旨在提供一系列纯函数,这些函数在处理数据时不会产生副作用,确保函数的输入和输出之间的映射关系是确定的。这使得代码更易于测试、维护和复用。
16
+
17
+ ## 许可证
18
+
19
19
  [MIT](https://opensource.org/licenses/MIT)
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { ArcStyleType, PolygonStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<ArcStyleType, [number, number]>>[0] & {
5
6
  /** 是否填充 */
6
7
  isFill?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { ArcToStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<ArcToStyleType, [number, number][]>>[0] & {
5
6
  /** 是否可显示控制点 */
6
7
  isHandlePointsVisible?: boolean;
@@ -1,5 +1,6 @@
1
1
  import { OverlayType } from './index';
2
2
  import { default as GeometricBoundary } from './public/geometricBoundary';
3
+ import { LineStyleType } from '../common.type';
3
4
  type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<LineStyleType>>[0] & {
4
5
  /** 是否是 两点相连向外延展的无限线 */
5
6
  isInfinite?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { PointStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<PointStyleType, [number, number]>>[0];
5
6
  export default class Point extends Overlay<PointStyleType, [number, number]> {
6
7
  private angle;
@@ -1,5 +1,6 @@
1
1
  import { OverlayType } from './index';
2
2
  import { default as GeometricBoundary } from './public/geometricBoundary';
3
+ import { PolygonStyleType } from '../common.type';
3
4
  type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<PolygonStyleType>>[0] & {
4
5
  /** 是否为矩形 */
5
6
  isRect?: boolean;
@@ -1,9 +1,11 @@
1
1
  import { default as _Canvas } from '../..';
2
2
  import { OverlayType } from '../index';
3
3
  import { EventHandler, default as EventController } from '../../public/eventController';
4
+ import { _Type_DeepPartial } from '../../..';
5
+ import { BaseLineStyle, PointStyleType } from '../../common.type';
4
6
  type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0] & {
5
7
  /** 样式 */
6
- style?: DeepPartial<T> | string;
8
+ style?: _Type_DeepPartial<T> | string;
7
9
  /** 层级 */
8
10
  zIndex?: number;
9
11
  /** 坐标轴上的点位 */
@@ -69,7 +71,7 @@ export default abstract class Overlay<T, V extends [number, number] | [number, n
69
71
  value?: V;
70
72
  dynamicPosition?: V;
71
73
  zIndex?: number;
72
- style?: DeepPartial<T> | string;
74
+ style?: _Type_DeepPartial<T> | string;
73
75
  }, updateValueScope?: boolean): void;
74
76
  /** 鼠标移入时是否重新绘制 */
75
77
  redrawOnIsHoverChange: boolean;
@@ -1,6 +1,7 @@
1
1
  import { default as Overlay } from './public/overlay';
2
2
  import { OverlayType } from './index';
3
3
  import { EventHandler } from '../public/eventController';
4
+ import { TextStyleType } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof Overlay<TextStyleType, [number, number]>>[0] & {
5
6
  /** 文字 */
6
7
  text?: string;
@@ -0,0 +1,117 @@
1
+ /** 默认中心点 */
2
+ export type DefaultCenter = Partial<{
3
+ top: number | `${number}%` | "top" | "middle" | "bottom";
4
+ bottom: number | `${number}%`;
5
+ left: number | `${number}%` | "left" | "center" | "right";
6
+ right: number | `${number}%`;
7
+ }>;
8
+ export type KnownStyleKeys = "light" | "dark";
9
+ /** 文本样式 */
10
+ export type TextStyleType = {
11
+ /** 颜色 */
12
+ color: string;
13
+ /** secondary颜色 */
14
+ secondary: string;
15
+ /** 描边色 */
16
+ stroke: string;
17
+ /** 字体大小 */
18
+ size: number;
19
+ /** 字体族 */
20
+ family: string;
21
+ /** 是否加粗 */
22
+ bold: boolean;
23
+ };
24
+ /** 网格样式 */
25
+ export type GridStyleType = {
26
+ axis: string;
27
+ grid: string;
28
+ innerGrid: string;
29
+ };
30
+ /** 点位样式 */
31
+ export type PointStyleType = {
32
+ /** 半径 */
33
+ radius: number;
34
+ /** 边框颜色 */
35
+ stroke: string;
36
+ /** 边框大小 */
37
+ width: number;
38
+ /** 填充颜色 */
39
+ fill: string;
40
+ };
41
+ /** 基础线样式 */
42
+ export type BaseLineStyle = {
43
+ /** 颜色 */
44
+ color: string;
45
+ /** 颜色 - hover */
46
+ color_hover: string;
47
+ /** 宽度 */
48
+ width: number;
49
+ /** 虚线 */
50
+ dash: boolean;
51
+ /** 虚线间隔 */
52
+ dashGap: number[];
53
+ /** 偏移虚线 */
54
+ dashOffset: number;
55
+ /** 末端的形状 */
56
+ cap: "butt" | "round" | "square";
57
+ /** 路径中的相连部分的形状 */
58
+ join: "bevel" | "round" | "miter";
59
+ };
60
+ /** 线样式 */
61
+ export type LineStyleType = {
62
+ /** 描边 */
63
+ stroke: BaseLineStyle;
64
+ /** 点位样式 */
65
+ point: PointStyleType;
66
+ };
67
+ /** 圆弧样式 */
68
+ export type ArcStyleType = {
69
+ /** 填充色 */
70
+ fill: string;
71
+ /** 填充色 - hover */
72
+ fill_hover: string;
73
+ /** 描边 */
74
+ stroke: BaseLineStyle;
75
+ /** 点位样式 */
76
+ point: PointStyleType;
77
+ };
78
+ /** 圆角样式 */
79
+ export type ArcToStyleType = {
80
+ /** 描边 */
81
+ stroke: BaseLineStyle;
82
+ /** 点位样式 */
83
+ point: PointStyleType;
84
+ };
85
+ /** 面样式 */
86
+ export type PolygonStyleType = {
87
+ /** 填充色 */
88
+ fill: string;
89
+ /** 填充色 - hover */
90
+ fill_hover: string;
91
+ /** 描边 */
92
+ stroke: BaseLineStyle;
93
+ /** 点位样式 */
94
+ point: PointStyleType;
95
+ };
96
+ /** 主题样式 */
97
+ export type StyleItemType = {
98
+ /** 背景色 */
99
+ background: string;
100
+ /** 文本样式 */
101
+ text: TextStyleType;
102
+ /** 网格样式 */
103
+ grid: GridStyleType;
104
+ /** 点位样式 */
105
+ point: PointStyleType;
106
+ /** 线样式 */
107
+ line: LineStyleType;
108
+ /** 圆弧样式 */
109
+ arc: ArcStyleType;
110
+ /** 圆角样式 */
111
+ arcTo: ArcToStyleType;
112
+ /** 面样式 */
113
+ polygon: PolygonStyleType;
114
+ };
115
+ /** 主题样式 */
116
+ export type StyleType = Record<KnownStyleKeys, StyleItemType> & Record<string, StyleItemType>;
117
+ export type DeepArray<T> = T | T[] | DeepArray<T>[];
@@ -1,4 +1,5 @@
1
1
  import { default as Canvas } from '..';
2
+ import { _Type_DeepPartial } from '../..';
2
3
  export default class Axis {
3
4
  /** 画布 */
4
5
  private canvas;
@@ -18,7 +19,7 @@ export default class Axis {
18
19
  constructor(canvas: Canvas);
19
20
  private initAxisCanvas;
20
21
  /** 开关坐标轴 */
21
- toggleAxis(show?: boolean | DeepPartial<Axis["show"]>): void;
22
+ toggleAxis(show?: boolean | _Type_DeepPartial<Axis["show"]>): void;
22
23
  drawAxisAndGrid(): HTMLCanvasElement | undefined;
23
24
  private color;
24
25
  /** 绘制网格 */
@@ -1,6 +1,7 @@
1
1
  import { default as Axis } from './axis';
2
2
  import { default as LayerGroup } from '../LayerGroup';
3
3
  import { default as EventController } from '../public/eventController';
4
+ import { DefaultCenter } from '../common.type';
4
5
  type ConstructorOption = ConstructorParameters<typeof EventController>[0] & {
5
6
  /** 画布 id */
6
7
  id: string;
@@ -9,7 +9,6 @@ export default class Draw extends Style {
9
9
  currentDrawOverlays: OverlayType[];
10
10
  /** 计算坐标所需依赖 */
11
11
  private rely;
12
- private isResizeObserverFirstRun;
13
12
  constructor(option: ConstructorOption);
14
13
  /** 更新 计算坐标所需依赖 */
15
14
  private updateRely;
@@ -1,8 +1,10 @@
1
+ import { _Type_DeepPartial } from '../..';
1
2
  import { default as Axis } from './axis';
2
3
  import { default as Event } from './event';
3
4
  import { default as OverlayGroup, OverlayType } from '../OverlayGroup';
4
5
  import { default as LayerGroup } from '../LayerGroup';
5
6
  import { default as Layer } from '../LayerGroup/layer';
7
+ import { KnownStyleKeys, StyleType } from '../common.type';
6
8
  type NodeType = LayerGroup | Layer | OverlayGroup | OverlayType;
7
9
  type SingleOrArray<T> = T | T[];
8
10
  declare class QuickMethod_Get extends Event {
@@ -28,7 +30,7 @@ declare class QuickMethod_Set extends QuickMethod_Get {
28
30
  /** 缩小 */
29
31
  zoomOut(): void;
30
32
  /** 添加样式 */
31
- setStyle(style: DeepPartial<StyleType>): void;
33
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
32
34
  /** 设置主题 */
33
35
  setTheme(theme: KnownStyleKeys): void;
34
36
  /** 设置坐标轴 */
@@ -80,7 +82,7 @@ declare class QuickMethod_View extends QuickMethod_Set {
80
82
  }
81
83
  declare class QuickMethod_Toggle extends QuickMethod_View {
82
84
  /** 开关坐标轴 */
83
- toggleAxis(show?: boolean | DeepPartial<Axis["show"]>): void;
85
+ toggleAxis(show?: boolean | _Type_DeepPartial<Axis["show"]>): void;
84
86
  /** 开关点位 */
85
87
  togglePoint(show?: boolean): boolean;
86
88
  /** 开关线段 */
@@ -1,3 +1,5 @@
1
+ import { _Type_DeepPartial } from '../..';
2
+ import { KnownStyleKeys, StyleType } from '../common.type';
1
3
  import { default as BaseData } from './basedata';
2
4
  type ConstructorOption = ConstructorParameters<typeof BaseData>[0] & {
3
5
  theme?: KnownStyleKeys;
@@ -15,7 +17,7 @@ export default class Style extends BaseData {
15
17
  /** 清除画布 */
16
18
  clearScreen(fillBackground?: boolean): void;
17
19
  /** 设置样式 */
18
- setStyle(style: DeepPartial<StyleType>): void;
20
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
19
21
  /** 设置主题 */
20
22
  setTheme(theme: KnownStyleKeys): void;
21
23
  }
@@ -9,12 +9,24 @@ import { default as Polygon } from './OverlayGroup/polygon';
9
9
  import { default as Custom } from './OverlayGroup/custom';
10
10
  import { default as Arc } from './OverlayGroup/arc';
11
11
  import { default as ArcTo } from './OverlayGroup/arcTo';
12
+ import { DeepArray } from './common.type';
12
13
  export type * from './index.types';
13
14
  type ConstructorOption = ConstructorParameters<typeof QuickMethod>[0] & {
14
15
  /** 轴线显示属性 */
15
16
  axisShow?: Parameters<_Canvas["toggleAxis"]>[0];
16
17
  };
17
- /** 你好啊你好的画布工具 */
18
+ /**
19
+ * 你好啊你好的画布工具类
20
+ * 提供图形绘制、动态渲染等画布相关功能,支持复杂场景下的可视化展示
21
+ *
22
+ * 使用示例:
23
+ * - GitHub演示:
24
+ * - 基础画布: https://adminnhanh.github.io/nhanh-frontend-view/#/canvas/_Canvas
25
+ * - 动态图表(月牙定理): https://adminnhanh.github.io/nhanh-frontend-view/#/math/DynamicDiagram/%E6%9C%88%E7%89%99%E5%AE%9A%E7%90%86
26
+ * - 阿里云演示:
27
+ * - 基础画布: https://nhanh.xin/#/canvas/_Canvas
28
+ * - 动态图表(月牙定理): https://nhanh.xin/#/math/DynamicDiagram/%E6%9C%88%E7%89%99%E5%AE%9A%E7%90%86
29
+ */
18
30
  export declare class _Canvas extends QuickMethod {
19
31
  /** 图层群组 */
20
32
  static LayerGroup: typeof LayerGroup;
@@ -5,11 +5,31 @@
5
5
  */
6
6
  export declare function _File_Read(src: string): Promise<string>;
7
7
  /**
8
- * 下载文件
9
- * @param {string} href - 文件路径
10
- * @param {string} [fileName] - 导出文件名
8
+ * 下载文件并支持进度监控、超时控制和主动中止
9
+ *
10
+ * @param {Object} options - 下载配置选项
11
+ * @param {string} options.href - 文件的 URL 路径或下载地址,需确保跨域权限或同源
12
+ * @param {string} [options.fileName] - 可选,指定导出的文件名(不含扩展名时会自动从 href 提取)
13
+ * @param {Function} [options.onProgress] - 可选,下载进度回调函数
14
+ * @param {number} [options.onProgress.progress] - 进度百分比(0-100)
15
+ * @param {number} [options.timeout=30000] - 可选,超时时间(毫秒),默认 30 秒
16
+ * @param {boolean} [options.autoDownload=true] - 可选,是否自动执行下载操作,默认 true
17
+ * @returns {Object} 返回包含以下属性的对象:
18
+ * - promise: Promise 对象,成功时 resolve 下载的 Blob 数据,失败时 reject 错误信息
19
+ * - abort: 中止下载的函数,调用后会触发 abort 错误
20
+ * - download: 手动执行下载的函数(当 autoDownload 为 false 时使用)
11
21
  */
12
- export declare function _File_Download(href: string, fileName?: string): Promise<unknown>;
22
+ export declare function _File_Download(options: {
23
+ href: string;
24
+ fileName?: string;
25
+ onProgress?: (progress: number) => void;
26
+ timeout?: number;
27
+ autoDownload?: boolean;
28
+ }): {
29
+ promise: Promise<Blob>;
30
+ abort: () => false | void;
31
+ download: () => void;
32
+ };
13
33
  /**
14
34
  * 创建文件并下载
15
35
  * @param {BlobPart[]} content 文件内容
@@ -73,3 +73,39 @@ export declare function _Format_CamelCase(str: string, isRemoveDelimiter?: boole
73
73
  * @returns 裁减后的字符串
74
74
  */
75
75
  export declare function _Format_ExcludeSubstring(inputString: string, substringToDelete: string, delimiter?: string): string;
76
+ /**
77
+ * 处理不可见字符的转义和还原
78
+ * @param {string} str - 要处理的字符串
79
+ * @param {boolean} escape - true表示转义(默认),false表示还原
80
+ * @returns {string} 处理后的字符串
81
+ */
82
+ export declare function _Format_ToggleInvisibleChars(str: string, escape?: boolean): string;
83
+ declare const UnitConfigs: readonly [readonly ["年", number], readonly ["月", number], readonly ["周", number], readonly ["天", number], readonly ["时", number], readonly ["分", number], readonly ["秒", 1000], readonly ["毫秒", 1]];
84
+ type UnitName = (typeof UnitConfigs)[number][0];
85
+ /**
86
+ * 格式化毫秒数为易读的时间单位(基于固定换算规则)
87
+ * @param ms 待格式化的毫秒数(需为非负整数)
88
+ * @param maxUnit 最大单位限制(可选,如传入"天"则最大只显示到天,不显示年/月/周)
89
+ * 可选值:"年"|"月"|"周"|"天"|"时"|"分"|"秒"|"毫秒"
90
+ * @returns 格式化后的时间字符串(如 1.3秒、300毫秒、1,234年)
91
+ * @description
92
+ * 1. 单位换算规则(固定值,非自然时间):
93
+ * - 1年 = 365天(忽略闰年差异)
94
+ * - 1月 = 30天(忽略实际月份天数差异)
95
+ * - 1周 = 7天,1天 = 24小时,1小时 = 60分钟,1分钟 = 60秒,1秒 = 1000毫秒
96
+ * 2. 格式化逻辑:
97
+ * - 自动匹配不超过最大单位限制的最优单位(数值≥单位阈值时使用该单位)
98
+ * - 非整数数值保留1位小数(如1.3秒),整数自动去除末尾.0(如1秒而非1.0秒)
99
+ * - "年"单位数值会自动应用千分位格式化(如1,234年)
100
+ * 3. 输入校验:非整数或负数会返回"0毫秒"
101
+ */
102
+ export declare function _Format_MillisecondToReadable(ms: number, maxUnit?: UnitName): string;
103
+ /**
104
+ * 将数组按指定长度分割成多个子数组
105
+ * @param arr 要分割的原始数组
106
+ * @param size 每个子数组的长度
107
+ * @returns 分割后的二维数组
108
+ * @throws 当size小于1时抛出错误
109
+ */
110
+ export declare function _Format_ChunkArray<T>(arr: T[], size: number): T[][];
111
+ export {};
@@ -48,3 +48,9 @@ export declare function _Math_GetMidpoint(x1: number, y1: number, x2: number, y2
48
48
  * @returns 与边界的交点坐标
49
49
  */
50
50
  export declare function _Math_GetBoundaryIntersection(startPoint: [number, number], direction: [number, number], canvasWidth: number, canvasHeight: number): [number, number];
51
+ /**
52
+ * 角度制数学工具代理
53
+ * 对于三角函数:自动将输入的角度转换为弧度
54
+ * 对于其他方法:直接调用原生Math方法
55
+ */
56
+ export declare const _Math_Degree: Math;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 将类型 T 中指定的属性 K 改为必填,其他属性保持原有状态(必填/可选)
3
+ * @template T - 原始类型
4
+ * @template K - 需要改为必填的属性集合(必须是 T 的属性键)
5
+ * @returns 新类型,其中 K 对应的属性为必填,其他属性保持 T 中原有的状态
6
+ * @example
7
+ * type User = { name?: string; age?: number; id: string }
8
+ * type RequiredName = RequiredBy<User, 'name'>
9
+ * // 结果:{ name: string; age?: number; id: string }
10
+ */
11
+ export type _Type_RequiredBy<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
12
+ /**
13
+ * 将类型 T 中指定的属性 K 改为可选,其他属性保持原有状态(必填/可选)
14
+ * @template T - 原始类型
15
+ * @template K - 需要改为可选的属性集合(必须是 T 的属性键)
16
+ * @returns 新类型,其中 K 对应的属性为可选,其他属性保持 T 中原有的状态
17
+ * @example
18
+ * type User = { name: string; age: number; id?: string }
19
+ * type OptionalAge = PartialBy<User, 'age'>
20
+ * // 结果:{ name: string; age?: number; id?: string }
21
+ */
22
+ export type _Type_PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
23
+ /**
24
+ * 递归将类型T的所有属性(包括嵌套对象的属性)转为可选
25
+ * @template T - 要处理的基础类型
26
+ * @description 与TypeScript内置的Partial不同,DeepPartial会对嵌套对象进行递归处理,
27
+ * 使所有层级的属性都变为可选。适用于需要部分更新对象且允许深层属性缺失的场景
28
+ */
29
+ export type _Type_DeepPartial<T> = {
30
+ [P in keyof T]?: T[P] extends object ? _Type_DeepPartial<T[P]> : T[P];
31
+ };
32
+ /**
33
+ * @template T - 要处理的对象类型
34
+ * @description 创建一个对象类型,将所有属性变为可变(mutable)。
35
+ * 适用于需要修改对象属性的场景,但需要确保对象不会被其他地方引用
36
+ */
37
+ export type _Type_Mutable<T> = {
38
+ -readonly [P in keyof T]: T[P];
39
+ };
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * 寻找空闲时机执行传入方法
3
3
  * @param callback 需执行的方法
4
+ * @param timeout 超时时间
4
5
  */
5
- export declare function _Utility_ExecuteWhenIdle(callback: Function): void;
6
+ export declare function _Utility_ExecuteWhenIdle(callback: Function, timeout?: number): void;
6
7
  /**
7
8
  * 等待条件满足
8
9
  * @param conditionChecker 条件检查器
@@ -3,4 +3,4 @@ export interface Point {
3
3
  y: number;
4
4
  }
5
5
  /** 定义所有可能的数据类型字符串 */
6
- export type DataType = "null" | "undefined" | "boolean" | "number" | "string" | "symbol" | "bigint" | "function" | "array" | "object" | "date" | "regexp" | "map" | "set" | "error" | "promise" | "weakmap" | "weakset" | "arraybuffer" | "dataview" | "int8array" | "uint8array" | "uint8clampedarray" | "int16array" | "uint16array" | "int32array" | "uint32array" | "float32array" | "float64array" | "bigint64array" | "biguint64array";
6
+ export type DataType = "null" | "undefined" | "boolean" | "number" | "string" | "symbol" | "bigint" | "function" | "array" | "object" | "date" | "regexp" | "map" | "set" | "error" | "promise" | "weakmap" | "weakset" | "file" | "arraybuffer" | "dataview" | "int8array" | "uint8array" | "uint8clampedarray" | "int16array" | "uint16array" | "int32array" | "uint32array" | "float32array" | "float64array" | "bigint64array" | "biguint64array";