minutool 1.0.15 → 1.0.16

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
@@ -174,6 +174,16 @@ export declare const buildHtmlHidden: (maps: Record<string, any>) => string;
174
174
  */
175
175
  export declare const buildStyleVars: (vars: Record<string, number | string | undefined>) => Record<string, string>;
176
176
 
177
+ /**
178
+ * 计算剩余时间,单位为毫秒
179
+ * @param progress 当前进度
180
+ * @param total 总进度
181
+ * @param startTime 开始时间(毫秒时间戳)
182
+ * @returns 剩余时间,单位毫秒
183
+ * @description 根据当前进度、总进度和已用时间估算剩余时间。公式为:剩余时间 = (已用时间 / 当前进度) * (总进度 - 当前进度)。如果当前进度为0,则返回Infinity。
184
+ */
185
+ export declare const calcRemainingMSecs: (progress: number, total: number, startTime: number) => number;
186
+
177
187
  /**
178
188
  * 驼峰命名转换
179
189
  * @param str - 输入字符串
@@ -207,9 +217,6 @@ export declare const convertMinutesToTimezoneOffsetStr: (offsetMinutes: number)
207
217
 
208
218
  /**
209
219
  * 倒计时函数(该方法采用 setTimeout 方式,不够精准)
210
- * @param {number} timeout - 倒计时总秒数
211
- * @param {Function} [tickFunc] - 每秒回调函数,接收剩余秒数作为参数
212
- * @param {Function} [onFinish] - 倒计时结束回调函数
213
220
  * @returns {void}
214
221
  * @example
215
222
  * countDown(10, (sec) => console.log(sec), () => console.log('done'))
@@ -443,23 +450,17 @@ export declare const fileToBase64DataUri: (file: File | Blob | string) => Promis
443
450
 
444
451
  /**
445
452
  * 通过选择器查找子节点(强制添加 :scope 来约束必须是子节点)
446
- * @param {string|HTMLElement|HTMLElement[]|NodeList|HTMLCollection} selector - 选择器或 DOM 元素
447
- * @param {Document|HTMLElement} [parent=document] - 父节点,默认为 document
448
- * @returns {HTMLElement[]} 返回查找到的所有元素数组
449
453
  * @example
450
454
  * findAll('.item', container)
451
455
  */
452
- export declare const findAll: (selector: string | HTMLElement | HTMLElement[] | NodeList | HTMLCollection, parent?: Document | HTMLElement) => HTMLElement[];
456
+ export declare const findAll: (selector: string | Element | Element[], parent?: Document | DocumentFragment | Element) => Element[];
453
457
 
454
458
  /**
455
459
  * 通过选择器查找单个节点
456
- * @param {string|HTMLElement} selector - 选择器,如果是 HTMLElement,则直接返回
457
- * @param {Document|HTMLElement} [parent=document] - 父节点,默认为 document
458
- * @returns {HTMLElement} 返回查找到的元素
459
460
  * @example
460
461
  * findOne('.item')
461
462
  */
462
- export declare const findOne: (selector: string | HTMLElement, parent?: Document | HTMLElement) => HTMLElement;
463
+ export declare const findOne: (selector: string | Element, parent?: Document | DocumentFragment | Element) => Element | null;
463
464
 
464
465
  /**
465
466
  * 修复基本 URL(将相对路径转换为绝对 URL)
@@ -587,6 +588,7 @@ export declare const guid: (prefix?: string) => string;
587
588
 
588
589
  /**
589
590
  * 隐藏节点(通过设置 display:none 方式)
591
+ * 注:只有 HTMLElement 才有 style 属性,其他类型的 Node 没有,因此需要断言为 HTMLElement
590
592
  * @param {HTMLElement|string} dom - DOM 元素或选择器
591
593
  * @returns {void}
592
594
  * @example
@@ -1178,8 +1180,6 @@ export declare const MONTH_NOW: number;
1178
1180
 
1179
1181
  /**
1180
1182
  * 毫秒转换为“时分秒前”格式
1181
- * @param {number} ms - 毫秒数
1182
- * @returns {string} 返回格式化后的字符串
1183
1183
  * @example
1184
1184
  * msToHMS(3661000) // '1小时0分钟1秒前'
1185
1185
  */
@@ -1517,6 +1517,7 @@ export declare const setCookie: (name: string, value: string, days: number, path
1517
1517
 
1518
1518
  /**
1519
1519
  * 显示节点(通过设置 display 为空方式)
1520
+ * 注:只有 HTMLElement 才有 style 属性,其他类型的 Node 没有,因此需要断言为 HTMLElement
1520
1521
  * @param {HTMLElement|string} dom - DOM 元素或选择器
1521
1522
  * @returns {void}
1522
1523
  * @example
@@ -1621,6 +1622,15 @@ export declare const throttle: (fn: Function, intervalMiSec: number) => Function
1621
1622
  */
1622
1623
  export declare const throttleEffect: (fn: Function, intervalMiSec: number) => Function;
1623
1624
 
1625
+ /**
1626
+ * 将时间戳转换为本地时间的日期时间字符串(YYYY-MM-DDTHH:mm),
1627
+ * 一般用于填充到 input[type="datetime-local"] 的 value 属性中
1628
+ * @param timestamp 时间戳,可以是数字、字符串或 Date 对象
1629
+ * @param includeSec 是否包含秒,默认为 false,如果为 true 则返回的字符串格式为 YYYY-MM-DDTHH:mm:ss
1630
+ * @returns 本地时间的日期时间字符串,格式为 YYYY-MM-DDTHH:mm:ss(如果 includeSec 参数为 true 则包含秒)
1631
+ */
1632
+ export declare const timestampToDateTimeLocal: (timestamp: number | string | Date, includeSec?: boolean) => string;
1633
+
1624
1634
  /**
1625
1635
  * 禁用启用元素切换
1626
1636
  * @param {String|Node} el