minutool 1.0.9 → 1.0.11

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
@@ -40,11 +40,13 @@ export declare const arrayColumn: <T = any>(arr: T[], col_name: keyof T) => any[
40
40
  /**
41
41
  * 数组去重
42
42
  * @param {T[]} arr - 源数组
43
+ * @param {function} [payload] - 可选的函数,用于生成唯一键值
43
44
  * @returns {T[]} 去重后的数组
44
45
  * @example
45
46
  * arrayDistinct([1, 2, 2, 3, 3, 3]) // [1, 2, 3]
47
+ * arrayDistinct([{id: 1}, {id: 2}, {id: 1}], (item, index) => item.id) // [{id: 1}, {id: 2}]
46
48
  */
47
- export declare const arrayDistinct: <T = any>(arr: T[]) => T[];
49
+ export declare const arrayDistinct: <T = any>(arr: T[], payload?: (item: T, index: number) => any) => T[];
48
50
 
49
51
  /**
50
52
  * 按指定键对数组进行分组
@@ -341,6 +343,14 @@ declare interface Dimension {
341
343
  */
342
344
  export declare const disabled: (el: HTMLElement | string, disabledClass?: string) => void;
343
345
 
346
+ /**
347
+ * 发布事件
348
+ * @param {string} event 事件名称
349
+ * @param {any} detail 事件详情
350
+ */
351
+ declare const dispatchEvent_2: (event: string, detail?: any) => void;
352
+ export { dispatchEvent_2 as dispatchEvent }
353
+
344
354
  /**
345
355
  * 下载文件
346
356
  * @param {string} uri - 文件 URI(支持 Data URI 和普通 URL)
@@ -1225,6 +1235,13 @@ export declare function objectSet(obj: any, path: string, value: any): void;
1225
1235
  */
1226
1236
  export declare const objToQuery: (data: Record<string, any>) => string;
1227
1237
 
1238
+ /**
1239
+ * 取消订阅事件
1240
+ * @param {string} event 事件名称
1241
+ * @param {Function} handler 事件处理函数
1242
+ */
1243
+ export declare const offEvent: (event: string, handler: EventListenerOrEventListenerObject) => void;
1244
+
1228
1245
  /**
1229
1246
  * 监听节点树变更
1230
1247
  * @param {HTMLElement} dom - 要监听的 DOM 节点
@@ -1252,6 +1269,13 @@ export declare const ONE_YEAR365: number;
1252
1269
 
1253
1270
  export declare const ONE_YEAR366: number;
1254
1271
 
1272
+ /**
1273
+ * 订阅事件
1274
+ * @param {string} event 事件名称
1275
+ * @param {Function} handler 事件处理函数
1276
+ */
1277
+ export declare const onEvent: (event: string, handler: EventListenerOrEventListenerObject) => void;
1278
+
1255
1279
  export declare const onHover: (el: HTMLElement | string, onHoverIn: () => void, onHoverOut: () => void) => void;
1256
1280
 
1257
1281
  /**