minutool 1.0.22 → 1.0.23

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/dist/index.d.ts CHANGED
@@ -99,16 +99,6 @@ export declare const arraySortByKey: <T extends Record<string, any>>(obj: T) =>
99
99
  */
100
100
  export declare const arrayTrimTail: (arr: any[]) => any[];
101
101
 
102
- /**
103
- * 类型断言辅助函数:明确告诉 TypeScript 某个值是 AbortablePromise
104
- * 用于解决 TypeScript 类型推导在某些情况下无法识别 AbortablePromise 的问题
105
- * @param promise - 实际上是 AbortablePromise 的对象
106
- * @returns 带有正确类型的 AbortablePromise
107
- * @example
108
- * const req = asAbortable(abortableFetch('/api').then(res => res.json()));
109
- */
110
- export declare const asAbortable: <T>(promise: any) => AbortablePromise<T>;
111
-
112
102
  /**
113
103
  * Base64 解码
114
104
  * @param {string} text - Base64 编码的字符串
@@ -152,7 +142,7 @@ export declare const between: (val: number, min: number, max: number, includeEqu
152
142
  * @param payload - 事件回调函数
153
143
  * @returns 解绑函数
154
144
  */
155
- export declare const bindClick: (element: HTMLElement | string, payload: (event: Event) => void) => () => void;
145
+ export declare const bindClick: (element: EventTarget | string, payload: (event: Event) => void) => () => void;
156
146
 
157
147
  /**
158
148
  * 绑定DOM事件,并返回一个解绑函数
@@ -161,7 +151,7 @@ export declare const bindClick: (element: HTMLElement | string, payload: (event:
161
151
  * @param payload - 事件回调函数
162
152
  * @returns 解绑函数
163
153
  */
164
- export declare const bindDomEvent: (element: HTMLElement | string, eventName: string, payload: (event: Event) => void) => () => void;
154
+ export declare const bindDomEvent: <E extends Event = Event>(element: EventTarget | string, eventName: string, payload: (event: E) => void) => () => void;
165
155
 
166
156
  /**
167
157
  * 绑定双击事件,并返回一个解绑函数
@@ -169,7 +159,7 @@ export declare const bindDomEvent: (element: HTMLElement | string, eventName: st
169
159
  * @param payload - 事件回调函数
170
160
  * @returns 解绑函数
171
161
  */
172
- export declare const bindDoubleClick: (element: HTMLElement | string, payload: (event: Event) => void) => () => void;
162
+ export declare const bindDoubleClick: (element: EventTarget | string, payload: (event: Event) => void) => () => void;
173
163
 
174
164
  /**
175
165
  * 绑定键盘按键按下事件,并返回一个解绑函数
@@ -177,7 +167,7 @@ export declare const bindDoubleClick: (element: HTMLElement | string, payload: (
177
167
  * @param payload - 事件回调函数
178
168
  * @returns 解绑函数
179
169
  */
180
- export declare const bindKeyDown: (element: HTMLElement | string, payload: (event: Event) => void) => () => void;
170
+ export declare const bindKeyDown: (element: EventTarget | string, payload: (event: Event) => void) => () => void;
181
171
 
182
172
  /**
183
173
  * 绑定键盘按键抬起事件,并返回一个解绑函数
@@ -185,7 +175,7 @@ export declare const bindKeyDown: (element: HTMLElement | string, payload: (even
185
175
  * @param payload - 事件回调函数
186
176
  * @returns 解绑函数
187
177
  */
188
- export declare const bindKeyUp: (element: HTMLElement | string, payload: (event: Event) => void) => () => void;
178
+ export declare const bindKeyUp: (element: EventTarget | string, payload: (event: Event) => void) => () => void;
189
179
 
190
180
  /**
191
181
  * 绑定对象移动事件
@@ -495,7 +485,7 @@ export declare const escapeHtml: (str: string, tabSize?: number, allowLineBreake
495
485
  * @param handler 事件处理函数, 参数为事件对象和匹配的子元素 (event, target)
496
486
  * @return 返回一个取消事件委托的函数
497
487
  */
498
- export declare const eventDelegate: (parent: HTMLElement | string, selector: string, event: string, handler: (event: Event, target: HTMLElement) => void) => () => void;
488
+ export declare const eventDelegate: (parent: EventTarget | string, selector: string, event: string, handler: (event: Event, target: Element) => void) => () => void;
499
489
 
500
490
  /**
501
491
  * 退出全屏模式
@@ -1845,7 +1835,7 @@ export declare const toggleFullScreen: (element: any) => Promise<unknown>;
1845
1835
  * @param node HTML节点
1846
1836
  * @param event 事件名称
1847
1837
  */
1848
- export declare const triggerDomEvent: (node: HTMLElement, event: string) => void;
1838
+ export declare const triggerDomEvent: (node: EventTarget, event: string) => void;
1849
1839
 
1850
1840
  /**
1851
1841
  * 去除字符串首尾指定字符或空白