minutool 1.0.13 → 1.0.15
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 +22 -4
- package/dist/minutool.js +622 -586
- 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
|
@@ -17,6 +17,10 @@ export declare interface AbortablePromise<T> extends Promise<T> {
|
|
|
17
17
|
abort: () => void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export declare class AbortError extends Error {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* 将数组分割成指定大小的块
|
|
22
26
|
* @param {T[]} list - 源数组
|
|
@@ -199,6 +203,8 @@ export declare function capitalize(str: string): string;
|
|
|
199
203
|
*/
|
|
200
204
|
export declare const cleanNull: (obj: any, recursive?: boolean) => any;
|
|
201
205
|
|
|
206
|
+
export declare const convertMinutesToTimezoneOffsetStr: (offsetMinutes: number) => string;
|
|
207
|
+
|
|
202
208
|
/**
|
|
203
209
|
* 倒计时函数(该方法采用 setTimeout 方式,不够精准)
|
|
204
210
|
* @param {number} timeout - 倒计时总秒数
|
|
@@ -533,6 +539,22 @@ export declare const getJson: (url: string, data?: any, option?: RequestOption)
|
|
|
533
539
|
*/
|
|
534
540
|
export declare const getNodeXPath: (el: HTMLElement | null) => string | null;
|
|
535
541
|
|
|
542
|
+
/**
|
|
543
|
+
* 根据时区名称获取该时区相对于 UTC 的分钟偏移量(分钟)
|
|
544
|
+
* @param timeZone - 时区名称(如 "America/New_York")
|
|
545
|
+
* @param date - 可选的日期对象,默认为当前时间
|
|
546
|
+
*/
|
|
547
|
+
export declare const getTimezoneOffsetMinutes: (timeZone: string) => number;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* 根据时区名称获取该时区相对于 UTC 的偏移字符串(格式为 "+HH:MM" 或 "-HH:MM")
|
|
551
|
+
* @param timeZone - 时区名称(如 "America/New_York")
|
|
552
|
+
* @returns 偏移字符串(如 "-05:00")
|
|
553
|
+
* @example
|
|
554
|
+
* getTimezoneOffsetStr("America/New_York") // "-05:00"
|
|
555
|
+
*/
|
|
556
|
+
export declare const getTimezoneOffsetStr: (timeZone: string) => string;
|
|
557
|
+
|
|
536
558
|
/**
|
|
537
559
|
* 获取 UTF-8 字符串长度(一个中文字按照 3 个字数计算)
|
|
538
560
|
* @param {string} str - 要计算的字符串
|
|
@@ -1445,18 +1467,14 @@ export declare const remove: (dom: HTMLElement | string) => Node | null;
|
|
|
1445
1467
|
* @param {string} url - 请求 URL
|
|
1446
1468
|
* @param {BodyInit|null} [data=null] - 请求数据,可以是字符串、FormData、URLSearchParams、Blob、ArrayBuffer 等,如果是对象会根据 ContentType 自动转换(例如 application/json 会自动 JSON.stringify)
|
|
1447
1469
|
* @param {RequestOption} option - 请求选项
|
|
1448
|
-
* @param {number} [option.timeout] - 请求超时时间(毫秒)
|
|
1449
|
-
* @param {number} [option.delay] - 延迟响应时间(毫秒),用于模拟慢速请求
|
|
1450
1470
|
* @returns {AbortablePromise<Response>} 返回可中止的 Promise
|
|
1451
1471
|
* @example
|
|
1452
1472
|
* request('/api/data', null, {method: 'GET'})
|
|
1453
|
-
* request('/api/data', null, {method: 'GET', delay: 2000}) // 延迟 2 秒响应
|
|
1454
1473
|
*/
|
|
1455
1474
|
export declare const request: (url: string, data: (BodyInit | null) | undefined, option: RequestOption) => AbortablePromise<Response>;
|
|
1456
1475
|
|
|
1457
1476
|
declare interface RequestOption extends RequestInit {
|
|
1458
1477
|
timeout?: number;
|
|
1459
|
-
delay?: number;
|
|
1460
1478
|
[key: string]: any;
|
|
1461
1479
|
}
|
|
1462
1480
|
|