minutool 1.0.29 → 1.0.31
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 +20 -12
- package/dist/minutool.js +189 -209
- package/dist/minutool.js.map +1 -1
- package/dist/minutool.umd.cjs +5 -5
- package/dist/minutool.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -191,7 +191,15 @@ export declare const bindKeyUp: (element: EventTarget | string, payload: (event:
|
|
|
191
191
|
* @param element - 要移动的元素
|
|
192
192
|
* @param handle - 拖动句柄,默认为元素本身
|
|
193
193
|
*/
|
|
194
|
-
export declare
|
|
194
|
+
export declare const bindNodeMove: (element: HTMLElement | string, handle?: HTMLElement | string | null) => () => void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 为指定的 localStorage key 绑定变化事件
|
|
198
|
+
* @param key - localStorage 的 key
|
|
199
|
+
* @param callback - 回调,参数为新的值
|
|
200
|
+
* @returns { destroy } - 解绑函数
|
|
201
|
+
*/
|
|
202
|
+
export declare const bindStorageEvent: (key: string, callback: (value: string | null) => void) => (() => void);
|
|
195
203
|
|
|
196
204
|
/**
|
|
197
205
|
* 转换 Blob 数据到 Base64 Data URL
|
|
@@ -255,13 +263,13 @@ export declare const calcRemainingMSecs: (progress: number, total: number, start
|
|
|
255
263
|
* camelCase('hello-world') // 'helloWorld'
|
|
256
264
|
* camelCase('hello_world') // 'helloWorld'
|
|
257
265
|
*/
|
|
258
|
-
export declare
|
|
266
|
+
export declare const camelCase: (str: string) => string;
|
|
259
267
|
|
|
260
268
|
/**
|
|
261
269
|
* 取消 el 上正在进行的滚动动画(若有),并还原 CSS 滚动行为
|
|
262
270
|
* @param el 要取消滚动动画的元素
|
|
263
271
|
*/
|
|
264
|
-
export declare
|
|
272
|
+
export declare const cancelScrollAnimation: (el: HTMLElement) => void;
|
|
265
273
|
|
|
266
274
|
/**
|
|
267
275
|
* 首字母大写
|
|
@@ -270,7 +278,7 @@ export declare function cancelScrollAnimation(el: HTMLElement): void;
|
|
|
270
278
|
* @example
|
|
271
279
|
* capitalize('hello') // 'Hello'
|
|
272
280
|
*/
|
|
273
|
-
export declare
|
|
281
|
+
export declare const capitalize: (str: string) => string;
|
|
274
282
|
|
|
275
283
|
/**
|
|
276
284
|
* 将任意数值限制到 [0, 1] 区间,常用于保证动画进度合法
|
|
@@ -375,7 +383,7 @@ export declare const decodeHTMLEntities: (str: string) => string;
|
|
|
375
383
|
* @example
|
|
376
384
|
* deepClone({ a: 1, b: { c: 2 } })
|
|
377
385
|
*/
|
|
378
|
-
export declare
|
|
386
|
+
export declare const deepClone: <T>(obj: T) => T;
|
|
379
387
|
|
|
380
388
|
/**
|
|
381
389
|
* 删除 Cookie
|
|
@@ -893,7 +901,7 @@ export declare const isChinese: (str: string) => boolean;
|
|
|
893
901
|
* isEmptyObject({}) // true
|
|
894
902
|
* isEmptyObject({ a: 1 }) // false
|
|
895
903
|
*/
|
|
896
|
-
export declare
|
|
904
|
+
export declare const isEmptyObject: (obj: object) => boolean;
|
|
897
905
|
|
|
898
906
|
/**
|
|
899
907
|
* 检测是否为 Firefox 浏览器
|
|
@@ -999,7 +1007,7 @@ export declare const isUrl: (str: string) => boolean;
|
|
|
999
1007
|
* kebabCase('helloWorld') // 'hello-world'
|
|
1000
1008
|
* kebabCase('HelloWorld') // 'hello-world'
|
|
1001
1009
|
*/
|
|
1002
|
-
export declare
|
|
1010
|
+
export declare const kebabCase: (str: string) => string;
|
|
1003
1011
|
|
|
1004
1012
|
/**
|
|
1005
1013
|
* 保持对象尽量在容器内部,优先保证上边、左边显示
|
|
@@ -1505,7 +1513,7 @@ export declare const objectFromEntries: <T extends Record<string | number | symb
|
|
|
1505
1513
|
* get({ a: { b: { c: 1 } } }, 'a.b.c') // 1
|
|
1506
1514
|
* get({ a: { b: 1 } }, 'a.b.c', 0) // 0
|
|
1507
1515
|
*/
|
|
1508
|
-
export declare
|
|
1516
|
+
export declare const objectGet: <T = any>(obj: object, path: string, defaultValue?: T) => T;
|
|
1509
1517
|
|
|
1510
1518
|
/**
|
|
1511
1519
|
* 根据映射关系替换对象的键
|
|
@@ -1525,7 +1533,7 @@ export declare const objectKeyReplace: (obj: Record<string, any>, mapping: Recor
|
|
|
1525
1533
|
* @example
|
|
1526
1534
|
* merge({ a: 1 }, { b: 2 }, { c: 3 }) // { a: 1, b: 2, c: 3 }
|
|
1527
1535
|
*/
|
|
1528
|
-
export declare
|
|
1536
|
+
export declare const objectMerge: <T extends object>(target: T, ...sources: Partial<T>[]) => T;
|
|
1529
1537
|
|
|
1530
1538
|
/**
|
|
1531
1539
|
* 设置对象指定路径的值
|
|
@@ -1535,7 +1543,7 @@ export declare function objectMerge<T extends object>(target: T, ...sources: Par
|
|
|
1535
1543
|
* @example
|
|
1536
1544
|
* set({}, 'a.b.c', 1) // { a: { b: { c: 1 } } }
|
|
1537
1545
|
*/
|
|
1538
|
-
export declare
|
|
1546
|
+
export declare const objectSet: (obj: any, path: string, value: any) => void;
|
|
1539
1547
|
|
|
1540
1548
|
/**
|
|
1541
1549
|
* 交换对象中的键值对
|
|
@@ -1828,7 +1836,7 @@ export declare type ScrollAxis = "scrollLeft" | "scrollTop";
|
|
|
1828
1836
|
* @param target 目标滚动位置
|
|
1829
1837
|
* @param options 动画选项
|
|
1830
1838
|
*/
|
|
1831
|
-
export declare
|
|
1839
|
+
export declare const scrollToAnimated: (el: HTMLElement, target: number, options?: ScrollToAnimatedOptions) => void;
|
|
1832
1840
|
|
|
1833
1841
|
export declare interface ScrollToAnimatedOptions {
|
|
1834
1842
|
/** 动画时长(ms),默认 380 */
|
|
@@ -2056,7 +2064,7 @@ export declare const TRIM_RIGHT = 2;
|
|
|
2056
2064
|
* @example
|
|
2057
2065
|
* truncate('hello world', 5) // 'hello...'
|
|
2058
2066
|
*/
|
|
2059
|
-
export declare
|
|
2067
|
+
export declare const truncate: (str: string, length: number, suffix?: string) => string;
|
|
2060
2068
|
|
|
2061
2069
|
/**
|
|
2062
2070
|
* 反转义 HTML(将 HTML 实体转换为字符)
|