minutool 1.0.22 → 1.0.24

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
  * 绑定对象移动事件
@@ -291,13 +281,11 @@ export declare const countDown: (timeout: number, tickFunc?: (timeout: number) =
291
281
 
292
282
  /**
293
283
  * 创建 HTML 节点
294
- * @param {string} html - HTML 字符串
295
- * @param {HTMLElement|null} [parentNode=null] - 父级节点,如果提供则自动添加到父节点
296
- * @returns {Node|Node[]} 返回创建的节点,单个或多个
297
- * @example
298
- * createDomByHtml('<div>Hello</div>')
284
+ * @param html - HTML 字符串
285
+ * @param [parentNode=null] - 父级节点,如果提供则自动添加到父节点
286
+ * @returns 返回创建的元素,单个或多个
299
287
  */
300
- export declare const createDomByHtml: (html: string, parentNode?: HTMLElement | null) => Node | Node[];
288
+ export declare const createDomByHtml: <T extends Element = Element>(html: string, parentNode?: HTMLElement | null) => T | T[];
301
289
 
302
290
  /**
303
291
  * CSS 选择器转义(处理特殊字符)
@@ -495,7 +483,7 @@ export declare const escapeHtml: (str: string, tabSize?: number, allowLineBreake
495
483
  * @param handler 事件处理函数, 参数为事件对象和匹配的子元素 (event, target)
496
484
  * @return 返回一个取消事件委托的函数
497
485
  */
498
- export declare const eventDelegate: (parent: HTMLElement | string, selector: string, event: string, handler: (event: Event, target: HTMLElement) => void) => () => void;
486
+ export declare const eventDelegate: (parent: EventTarget | string, selector: string, event: string, handler: (event: Event, target: Element) => void) => () => void;
499
487
 
500
488
  /**
501
489
  * 退出全屏模式
@@ -1845,7 +1833,7 @@ export declare const toggleFullScreen: (element: any) => Promise<unknown>;
1845
1833
  * @param node HTML节点
1846
1834
  * @param event 事件名称
1847
1835
  */
1848
- export declare const triggerDomEvent: (node: HTMLElement, event: string) => void;
1836
+ export declare const triggerDomEvent: (node: EventTarget, event: string) => void;
1849
1837
 
1850
1838
  /**
1851
1839
  * 去除字符串首尾指定字符或空白