minutool 1.0.8 → 1.0.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/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 => 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) => any) => T[];
48
50
 
49
51
  /**
50
52
  * 按指定键对数组进行分组
@@ -773,6 +775,8 @@ export declare const loadScript: (src: string, forceReload?: boolean) => Promise
773
775
  */
774
776
  export declare const lockElementInteraction: (el: HTMLElement | string, payload: (reset: () => void) => void) => void;
775
777
 
778
+ export declare const markdown2Html: (md: string) => string;
779
+
776
780
  /**
777
781
  * 计算字符串的 MD5 哈希值
778
782
  * @param {string} string - 要计算 MD5 的字符串
@@ -1541,6 +1545,15 @@ export declare const stripSlashes: (str: string) => string;
1541
1545
  */
1542
1546
  export declare const strToPascalCase: (str: string, capitalize_first?: boolean) => string;
1543
1547
 
1548
+ /**
1549
+ * 将纯文本转换为 HTML(转义特殊字符并处理换行)
1550
+ * @param {string} text - 纯文本字符串
1551
+ * @returns {string} 返回 HTML 字符串
1552
+ * @example
1553
+ * text2Html('Hello\nWorld') // 'Hello<br/>World'
1554
+ */
1555
+ export declare const text2Html: (text: string) => string;
1556
+
1544
1557
  /**
1545
1558
  * 节流函数
1546
1559
  * 规定在一个单位时间内,只能触发一次函数。如果这个函数单位时间内触发多次函数,只有一次生效。