@whitesev/utils 2.4.3 → 2.4.5
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.amd.js +18 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +18 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +18 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +18 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +18 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +18 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +17 -0
- package/dist/types/src/types/Httpx.d.ts +3 -4
- package/package.json +1 -1
- package/src/Httpx.ts +1 -1
- package/src/Utils.ts +35 -1
- package/src/types/Httpx.d.ts +3 -4
|
@@ -1698,6 +1698,23 @@ declare class Utils {
|
|
|
1698
1698
|
* > 111;
|
|
1699
1699
|
*/
|
|
1700
1700
|
watchObject(target: any, propertyName: string, getCallBack: (value: any) => void, setCallBack: (value: any) => void): void;
|
|
1701
|
+
/**
|
|
1702
|
+
* 深度获取对象属性
|
|
1703
|
+
* @param target 待获取的对象
|
|
1704
|
+
* @param handler 获取属性的回调
|
|
1705
|
+
*/
|
|
1706
|
+
queryProperty(target: any, handler: (target: any) => {
|
|
1707
|
+
/**
|
|
1708
|
+
* 是否是需要的属性
|
|
1709
|
+
* + true 将目标值赋值给data
|
|
1710
|
+
* + false 不是需要的,data为下一个处理的对象
|
|
1711
|
+
*/
|
|
1712
|
+
isFind: boolean;
|
|
1713
|
+
/**
|
|
1714
|
+
* 对象/目标值
|
|
1715
|
+
*/
|
|
1716
|
+
data: any;
|
|
1717
|
+
}): any;
|
|
1701
1718
|
/**
|
|
1702
1719
|
* 创建一个新的Utils实例
|
|
1703
1720
|
* @param option
|
|
@@ -1241,10 +1241,9 @@ export declare interface HttpxResponseData<T extends HttpxRequestOption> {
|
|
|
1241
1241
|
/**
|
|
1242
1242
|
* 响应内容,根据responseType,如果是html,那就是Document类型,如果是json,那么类型是Object类型
|
|
1243
1243
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
: T["responseType"];
|
|
1244
|
+
response: T["responseType"] extends keyof HttpxResponseTypeMap
|
|
1245
|
+
? HttpxResponseTypeMap[T["responseType"]]
|
|
1246
|
+
: HttpxResponseTypeMap["html"];
|
|
1248
1247
|
/**
|
|
1249
1248
|
* 当请求头fetch为true时,该属性存在
|
|
1250
1249
|
*/
|
package/package.json
CHANGED
package/src/Httpx.ts
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -29,7 +29,7 @@ class Utils {
|
|
|
29
29
|
this.windowApi = new WindowApi(option);
|
|
30
30
|
}
|
|
31
31
|
/** 版本号 */
|
|
32
|
-
version = "2024.
|
|
32
|
+
version = "2024.11.1";
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
|
|
@@ -4939,6 +4939,40 @@ class Utils {
|
|
|
4939
4939
|
}
|
|
4940
4940
|
}
|
|
4941
4941
|
|
|
4942
|
+
/**
|
|
4943
|
+
* 深度获取对象属性
|
|
4944
|
+
* @param target 待获取的对象
|
|
4945
|
+
* @param handler 获取属性的回调
|
|
4946
|
+
*/
|
|
4947
|
+
queryProperty(
|
|
4948
|
+
target: any,
|
|
4949
|
+
handler: (target: any) => {
|
|
4950
|
+
/**
|
|
4951
|
+
* 是否是需要的属性
|
|
4952
|
+
* + true 将目标值赋值给data
|
|
4953
|
+
* + false 不是需要的,data为下一个处理的对象
|
|
4954
|
+
*/
|
|
4955
|
+
isFind: boolean;
|
|
4956
|
+
/**
|
|
4957
|
+
* 对象/目标值
|
|
4958
|
+
*/
|
|
4959
|
+
data: any;
|
|
4960
|
+
}
|
|
4961
|
+
): any {
|
|
4962
|
+
if (target == null) {
|
|
4963
|
+
return;
|
|
4964
|
+
}
|
|
4965
|
+
let handleResult = handler(target);
|
|
4966
|
+
if (
|
|
4967
|
+
handleResult &&
|
|
4968
|
+
typeof handleResult.isFind === "boolean" &&
|
|
4969
|
+
handleResult.isFind
|
|
4970
|
+
) {
|
|
4971
|
+
return handleResult.data;
|
|
4972
|
+
}
|
|
4973
|
+
return this.queryProperty(handleResult.data, handler);
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4942
4976
|
/**
|
|
4943
4977
|
* 创建一个新的Utils实例
|
|
4944
4978
|
* @param option
|
package/src/types/Httpx.d.ts
CHANGED
|
@@ -1241,10 +1241,9 @@ export declare interface HttpxResponseData<T extends HttpxRequestOption> {
|
|
|
1241
1241
|
/**
|
|
1242
1242
|
* 响应内容,根据responseType,如果是html,那就是Document类型,如果是json,那么类型是Object类型
|
|
1243
1243
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
: T["responseType"];
|
|
1244
|
+
response: T["responseType"] extends keyof HttpxResponseTypeMap
|
|
1245
|
+
? HttpxResponseTypeMap[T["responseType"]]
|
|
1246
|
+
: HttpxResponseTypeMap["html"];
|
|
1248
1247
|
/**
|
|
1249
1248
|
* 当请求头fetch为true时,该属性存在
|
|
1250
1249
|
*/
|