@whitesev/utils 2.8.0 → 2.8.1
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/README.md +176 -176
- package/dist/index.amd.js +893 -874
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +893 -874
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +893 -874
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +893 -874
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +893 -874
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +893 -874
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/CommonUtil.d.ts +59 -59
- package/dist/types/src/DOMUtils.d.ts +1 -1
- package/dist/types/src/Dictionary.d.ts +1 -1
- package/dist/types/src/Httpx.d.ts +2 -2
- package/dist/types/src/Progress.d.ts +0 -4
- package/dist/types/src/TryCatch.d.ts +2 -2
- package/dist/types/src/Utils.d.ts +365 -365
- package/dist/types/src/UtilsGMCookie.d.ts +2 -2
- package/dist/types/src/UtilsGMMenu.d.ts +1 -1
- package/dist/types/src/indexedDB.d.ts +3 -3
- package/dist/types/src/types/Event.d.ts +188 -188
- package/dist/types/src/types/Httpx.d.ts +1344 -1343
- package/dist/types/src/types/Log.d.ts +19 -19
- package/dist/types/src/types/Progress.d.ts +20 -20
- package/dist/types/src/types/React.d.ts +119 -119
- package/dist/types/src/types/TryCatch.d.ts +9 -9
- package/dist/types/src/types/UtilsGMCookie.d.ts +93 -93
- package/dist/types/src/types/UtilsGMMenu.d.ts +77 -77
- package/dist/types/src/types/Vue2.d.ts +166 -166
- package/dist/types/src/types/WindowApi.d.ts +14 -14
- package/dist/types/src/types/ajaxHooker.d.ts +151 -151
- package/dist/types/src/types/env.d.ts +7 -2
- package/dist/types/src/types/global.d.ts +31 -31
- package/package.json +16 -7
- package/src/ColorConversion.ts +105 -106
- package/src/CommonUtil.ts +280 -279
- package/src/DOMUtils.ts +251 -272
- package/src/Dictionary.ts +153 -154
- package/src/GBKEncoder.ts +108 -112
- package/src/Hooks.ts +73 -81
- package/src/Httpx.ts +1457 -1466
- package/src/LockFunction.ts +62 -62
- package/src/Log.ts +258 -259
- package/src/ModuleRaid.js +1 -0
- package/src/Progress.ts +108 -114
- package/src/TryCatch.ts +86 -86
- package/src/Utils.ts +4772 -4825
- package/src/UtilsCommon.ts +14 -14
- package/src/UtilsGMCookie.ts +254 -261
- package/src/UtilsGMMenu.ts +445 -454
- package/src/Vue.ts +233 -229
- package/src/WindowApi.ts +59 -59
- package/src/ajaxHooker/ajaxHooker.js +1 -0
- package/src/indexedDB.ts +497 -502
- package/src/types/Event.d.ts +188 -188
- package/src/types/Httpx.d.ts +1344 -1343
- package/src/types/Log.d.ts +19 -19
- package/src/types/Progress.d.ts +20 -20
- package/src/types/React.d.ts +119 -119
- package/src/types/TryCatch.d.ts +9 -9
- package/src/types/UtilsGMCookie.d.ts +93 -93
- package/src/types/UtilsGMMenu.d.ts +77 -77
- package/src/types/Vue2.d.ts +166 -166
- package/src/types/WindowApi.d.ts +14 -14
- package/src/types/ajaxHooker.d.ts +151 -151
- package/src/types/env.d.ts +7 -2
- package/src/types/global.d.ts +31 -31
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
declare class CommonUtil {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
* JSON数据从源端替换到目标端中,如果目标端存在该数据则替换,不添加,返回结果为目标端替换完毕的结果
|
|
4
|
+
* @param target 目标数据
|
|
5
|
+
* @param source 源数据
|
|
6
|
+
* @param isAdd 是否可以追加键,默认false
|
|
7
|
+
* @example
|
|
8
|
+
* Utils.assign({"1":1,"2":{"3":3}}, {"2":{"3":4}});
|
|
9
|
+
* >
|
|
10
|
+
* {
|
|
11
|
+
"1": 1,
|
|
12
|
+
"2": {
|
|
13
|
+
"3": 4
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
*/
|
|
17
17
|
assign<T1, T2 extends object, T3 extends boolean>(target: T1, source: T2, isAdd?: T3): T3 extends true ? T1 & T2 : T1;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
19
|
+
* 判断对象或数据是否为空
|
|
20
|
+
* + `String`判空的值,如 ""、"null"、"undefined"、" "
|
|
21
|
+
* + `Number`判空的值,如 0
|
|
22
|
+
* + `Object`判空的值,如 {}、null、undefined
|
|
23
|
+
* + `Array`(存在属性Symbol.iterator)判空的值,如 []
|
|
24
|
+
* + `Boolean`判空的值,如false
|
|
25
|
+
* + `Function`判空的值,如()=>{}、(xxx="")=>{}、function(){}、function(xxx=""){}
|
|
26
|
+
* @returns
|
|
27
|
+
* + true 为空
|
|
28
|
+
* + false 不为空
|
|
29
|
+
* @example
|
|
30
|
+
Utils.isNull({});
|
|
31
|
+
> true
|
|
32
|
+
* @example
|
|
33
|
+
Utils.isNull([]);
|
|
34
|
+
> true
|
|
35
|
+
* @example
|
|
36
|
+
Utils.isNull(" ");
|
|
37
|
+
> true
|
|
38
|
+
* @example
|
|
39
|
+
Utils.isNull(function(){});
|
|
40
|
+
> true
|
|
41
|
+
* @example
|
|
42
|
+
Utils.isNull(()=>{}));
|
|
43
|
+
> true
|
|
44
|
+
* @example
|
|
45
|
+
Utils.isNull("undefined");
|
|
46
|
+
> true
|
|
47
|
+
* @example
|
|
48
|
+
Utils.isNull("null");
|
|
49
|
+
> true
|
|
50
|
+
* @example
|
|
51
|
+
Utils.isNull(" ", false);
|
|
52
|
+
> true
|
|
53
|
+
* @example
|
|
54
|
+
Utils.isNull([1],[]);
|
|
55
|
+
> false
|
|
56
|
+
* @example
|
|
57
|
+
Utils.isNull([],[1]);
|
|
58
|
+
> false
|
|
59
|
+
* @example
|
|
60
|
+
Utils.isNull(false,[123]);
|
|
61
|
+
> false
|
|
62
|
+
**/
|
|
63
63
|
isNull<T>(value: T | undefined | null): value is null | undefined;
|
|
64
64
|
isNull(...args: any[]): boolean;
|
|
65
65
|
/**
|
|
@@ -105,5 +105,5 @@ declare class CommonUtil {
|
|
|
105
105
|
*/
|
|
106
106
|
toJSON<T = any>(data: string | null, errorCallBack?: (error: Error) => void): T;
|
|
107
107
|
}
|
|
108
|
-
declare
|
|
108
|
+
declare const commonUtil: CommonUtil;
|
|
109
109
|
export { commonUtil as CommonUtil };
|
|
@@ -91,5 +91,5 @@ declare class DOMUtils {
|
|
|
91
91
|
closest<K extends keyof HTMLElementTagNameMap>($el: HTMLElement | Element, selector: string): HTMLElementTagNameMap[K] | null;
|
|
92
92
|
closest<E extends Element = Element>($el: HTMLElement | Element, selector: string): E | null;
|
|
93
93
|
}
|
|
94
|
-
declare
|
|
94
|
+
declare const domUtils: DOMUtils;
|
|
95
95
|
export { domUtils };
|
|
@@ -69,7 +69,7 @@ export declare class Httpx {
|
|
|
69
69
|
* 修改xmlHttpRequest
|
|
70
70
|
* @param httpRequest 网络请求函数
|
|
71
71
|
*/
|
|
72
|
-
setXMLHttpRequest(httpRequest:
|
|
72
|
+
setXMLHttpRequest(httpRequest: (...args: any[]) => any): void;
|
|
73
73
|
/**
|
|
74
74
|
* GET 请求
|
|
75
75
|
* @param details 配置
|
|
@@ -171,5 +171,5 @@ export declare class Httpx {
|
|
|
171
171
|
* @param details 配置
|
|
172
172
|
* @param beforeRequestOption 处理请求前的配置
|
|
173
173
|
*/
|
|
174
|
-
request<T extends HttpxRequestOption>(details: T, beforeRequestOption?: (option: Required<T>) => void): HttpxPromise<HttpxResponse<T>>;
|
|
174
|
+
request<T extends HttpxRequestOption>(details: T, beforeRequestOption?: (option: Required<T | HttpxRequestOption>) => void): HttpxPromise<HttpxResponse<T>>;
|
|
175
175
|
}
|
|
@@ -10,7 +10,7 @@ export declare const TryCatch: (...args: any) => {
|
|
|
10
10
|
* 处理错误
|
|
11
11
|
* @param handler
|
|
12
12
|
*/
|
|
13
|
-
error(handler: ((...args: any[]) => any) | string |
|
|
13
|
+
error(handler: ((...args: any[]) => any) | string | ((...args: any[]) => any)): /*elided*/ any;
|
|
14
14
|
/**
|
|
15
15
|
* 执行传入的函数并捕获其可能抛出的错误,并通过传入的错误处理函数进行处理。
|
|
16
16
|
* @param callback 待执行函数,可以是 function 或者 string 类型。如果是 string 类型,则会被当做代码进行执行。
|
|
@@ -18,5 +18,5 @@ export declare const TryCatch: (...args: any) => {
|
|
|
18
18
|
* @returns 如果函数有返回值,则返回该返回值;否则返回 tryCatchObj 函数以支持链式调用。
|
|
19
19
|
* @throws {Error} 如果传入参数不符合要求,则会抛出相应类型的错误。
|
|
20
20
|
*/
|
|
21
|
-
run<A extends any[], R>(callback: ((...args: A) => R) | string |
|
|
21
|
+
run<A extends any[], R>(callback: ((...args: A) => R) | string | ((...args: any[]) => any), __context__?: any): UtilsTryCatchType;
|
|
22
22
|
};
|