@whitesev/utils 2.8.0 → 2.8.2

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.
Files changed (71) hide show
  1. package/README.md +176 -176
  2. package/dist/index.amd.js +896 -875
  3. package/dist/index.amd.js.map +1 -1
  4. package/dist/index.cjs.js +896 -875
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.esm.js +896 -875
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.iife.js +896 -875
  9. package/dist/index.iife.js.map +1 -1
  10. package/dist/index.system.js +896 -875
  11. package/dist/index.system.js.map +1 -1
  12. package/dist/index.umd.js +896 -875
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/types/src/CommonUtil.d.ts +59 -59
  15. package/dist/types/src/DOMUtils.d.ts +1 -1
  16. package/dist/types/src/Dictionary.d.ts +1 -1
  17. package/dist/types/src/Httpx.d.ts +2 -2
  18. package/dist/types/src/Progress.d.ts +0 -4
  19. package/dist/types/src/TryCatch.d.ts +2 -2
  20. package/dist/types/src/Utils.d.ts +365 -365
  21. package/dist/types/src/UtilsGMCookie.d.ts +2 -2
  22. package/dist/types/src/UtilsGMMenu.d.ts +1 -1
  23. package/dist/types/src/indexedDB.d.ts +3 -3
  24. package/dist/types/src/types/Event.d.ts +188 -188
  25. package/dist/types/src/types/Httpx.d.ts +1344 -1343
  26. package/dist/types/src/types/Log.d.ts +19 -19
  27. package/dist/types/src/types/Progress.d.ts +20 -20
  28. package/dist/types/src/types/React.d.ts +119 -119
  29. package/dist/types/src/types/TryCatch.d.ts +9 -9
  30. package/dist/types/src/types/UtilsGMCookie.d.ts +93 -93
  31. package/dist/types/src/types/UtilsGMMenu.d.ts +77 -77
  32. package/dist/types/src/types/Vue2.d.ts +166 -166
  33. package/dist/types/src/types/WindowApi.d.ts +14 -14
  34. package/dist/types/src/types/ajaxHooker.d.ts +151 -151
  35. package/dist/types/src/types/env.d.ts +7 -2
  36. package/dist/types/src/types/global.d.ts +31 -31
  37. package/index.ts +3 -0
  38. package/package.json +19 -8
  39. package/src/ColorConversion.ts +105 -106
  40. package/src/CommonUtil.ts +280 -279
  41. package/src/DOMUtils.ts +251 -272
  42. package/src/Dictionary.ts +153 -154
  43. package/src/GBKEncoder.ts +108 -112
  44. package/src/Hooks.ts +73 -81
  45. package/src/Httpx.ts +1457 -1466
  46. package/src/LockFunction.ts +62 -62
  47. package/src/Log.ts +258 -259
  48. package/src/ModuleRaid.js +1 -0
  49. package/src/Progress.ts +108 -114
  50. package/src/TryCatch.ts +86 -86
  51. package/src/Utils.ts +4773 -4825
  52. package/src/UtilsCommon.ts +14 -14
  53. package/src/UtilsGMCookie.ts +254 -261
  54. package/src/UtilsGMMenu.ts +445 -454
  55. package/src/Vue.ts +233 -229
  56. package/src/WindowApi.ts +59 -59
  57. package/src/ajaxHooker/ajaxHooker.js +1 -0
  58. package/src/indexedDB.ts +497 -502
  59. package/src/types/Event.d.ts +188 -188
  60. package/src/types/Httpx.d.ts +1344 -1343
  61. package/src/types/Log.d.ts +19 -19
  62. package/src/types/Progress.d.ts +20 -20
  63. package/src/types/React.d.ts +119 -119
  64. package/src/types/TryCatch.d.ts +9 -9
  65. package/src/types/UtilsGMCookie.d.ts +93 -93
  66. package/src/types/UtilsGMMenu.d.ts +77 -77
  67. package/src/types/Vue2.d.ts +166 -166
  68. package/src/types/WindowApi.d.ts +14 -14
  69. package/src/types/ajaxHooker.d.ts +151 -151
  70. package/src/types/env.d.ts +7 -2
  71. package/src/types/global.d.ts +31 -31
@@ -1,65 +1,65 @@
1
1
  declare class CommonUtil {
2
2
  /**
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
- */
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
- * + `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
- **/
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 let commonUtil: CommonUtil;
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 let domUtils: DOMUtils;
94
+ declare const domUtils: DOMUtils;
95
95
  export { domUtils };
@@ -1,4 +1,4 @@
1
- export declare class UtilsDictionary<K extends unknown, V extends any> {
1
+ export declare class UtilsDictionary<K, V> {
2
2
  private items;
3
3
  constructor();
4
4
  constructor(key: K, value: V);
@@ -69,7 +69,7 @@ export declare class Httpx {
69
69
  * 修改xmlHttpRequest
70
70
  * @param httpRequest 网络请求函数
71
71
  */
72
- setXMLHttpRequest(httpRequest: Function): void;
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
  }
@@ -6,10 +6,6 @@ export declare class Progress {
6
6
  * @param paramConfig 配置信息
7
7
  */
8
8
  constructor(paramConfig: ProgressParamConfig);
9
- /**
10
- * 初始化
11
- */
12
- private init;
13
9
  /**
14
10
  * 绘制
15
11
  */
@@ -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 | Function): /*elided*/ any;
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 | Function, __context__?: any): UtilsTryCatchType;
21
+ run<A extends any[], R>(callback: ((...args: A) => R) | string | ((...args: any[]) => any), __context__?: any): UtilsTryCatchType;
22
22
  };