nhanh-pure-function 3.0.6-beta.6 → 3.0.6-beta.8

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.
@@ -1,9 +1,10 @@
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 '../../..';
4
5
  type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0] & {
5
6
  /** 样式 */
6
- style?: DeepPartial<T> | string;
7
+ style?: _Type_DeepPartial<T> | string;
7
8
  /** 层级 */
8
9
  zIndex?: number;
9
10
  /** 坐标轴上的点位 */
@@ -69,7 +70,7 @@ export default abstract class Overlay<T, V extends [number, number] | [number, n
69
70
  value?: V;
70
71
  dynamicPosition?: V;
71
72
  zIndex?: number;
72
- style?: DeepPartial<T> | string;
73
+ style?: _Type_DeepPartial<T> | string;
73
74
  }, updateValueScope?: boolean): void;
74
75
  /** 鼠标移入时是否重新绘制 */
75
76
  redrawOnIsHoverChange: boolean;
@@ -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,3 +1,4 @@
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';
@@ -28,7 +29,7 @@ declare class QuickMethod_Set extends QuickMethod_Get {
28
29
  /** 缩小 */
29
30
  zoomOut(): void;
30
31
  /** 添加样式 */
31
- setStyle(style: DeepPartial<StyleType>): void;
32
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
32
33
  /** 设置主题 */
33
34
  setTheme(theme: KnownStyleKeys): void;
34
35
  /** 设置坐标轴 */
@@ -80,7 +81,7 @@ declare class QuickMethod_View extends QuickMethod_Set {
80
81
  }
81
82
  declare class QuickMethod_Toggle extends QuickMethod_View {
82
83
  /** 开关坐标轴 */
83
- toggleAxis(show?: boolean | DeepPartial<Axis["show"]>): void;
84
+ toggleAxis(show?: boolean | _Type_DeepPartial<Axis["show"]>): void;
84
85
  /** 开关点位 */
85
86
  togglePoint(show?: boolean): boolean;
86
87
  /** 开关线段 */
@@ -1,3 +1,4 @@
1
+ import { _Type_DeepPartial } from '../..';
1
2
  import { default as BaseData } from './basedata';
2
3
  type ConstructorOption = ConstructorParameters<typeof BaseData>[0] & {
3
4
  theme?: KnownStyleKeys;
@@ -15,7 +16,7 @@ export default class Style extends BaseData {
15
16
  /** 清除画布 */
16
17
  clearScreen(fillBackground?: boolean): void;
17
18
  /** 设置样式 */
18
- setStyle(style: DeepPartial<StyleType>): void;
19
+ setStyle(style: _Type_DeepPartial<StyleType>): void;
19
20
  /** 设置主题 */
20
21
  setTheme(theme: KnownStyleKeys): void;
21
22
  }
@@ -100,4 +100,12 @@ type UnitName = (typeof UnitConfigs)[number][0];
100
100
  * 3. 输入校验:非整数或负数会返回"0毫秒"
101
101
  */
102
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[][];
103
111
  export {};
@@ -8,7 +8,7 @@
8
8
  * type RequiredName = RequiredBy<User, 'name'>
9
9
  * // 结果:{ name: string; age?: number; id: string }
10
10
  */
11
- export type RequiredBy<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
11
+ export type _Type_RequiredBy<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
12
12
  /**
13
13
  * 将类型 T 中指定的属性 K 改为可选,其他属性保持原有状态(必填/可选)
14
14
  * @template T - 原始类型
@@ -19,13 +19,21 @@ export type RequiredBy<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>
19
19
  * type OptionalAge = PartialBy<User, 'age'>
20
20
  * // 结果:{ name: string; age?: number; id?: string }
21
21
  */
22
- export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
22
+ export type _Type_PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
23
23
  /**
24
24
  * 递归将类型T的所有属性(包括嵌套对象的属性)转为可选
25
25
  * @template T - 要处理的基础类型
26
26
  * @description 与TypeScript内置的Partial不同,DeepPartial会对嵌套对象进行递归处理,
27
27
  * 使所有层级的属性都变为可选。适用于需要部分更新对象且允许深层属性缺失的场景
28
28
  */
29
- export type DeepPartial<T> = {
30
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
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];
31
39
  };