@whitesev/utils 2.3.1 → 2.3.3
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 +34 -6
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +34 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +34 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +34 -6
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +34 -6
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +34 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Httpx.d.ts +62 -12
- package/dist/types/src/Utils.d.ts +9 -0
- package/package.json +1 -1
- package/src/Httpx.ts +117 -38
- package/src/Utils.ts +39 -11
package/dist/index.esm.js
CHANGED
|
@@ -1753,6 +1753,8 @@ class Httpx {
|
|
|
1753
1753
|
data: details.data || this.context.#defaultDetails.data,
|
|
1754
1754
|
redirect: details.redirect || this.context.#defaultDetails.redirect,
|
|
1755
1755
|
cookie: details.cookie || this.context.#defaultDetails.cookie,
|
|
1756
|
+
cookiePartition: details.cookiePartition ||
|
|
1757
|
+
this.context.#defaultDetails.cookiePartition,
|
|
1756
1758
|
binary: details.binary || this.context.#defaultDetails.binary,
|
|
1757
1759
|
nocache: details.nocache || this.context.#defaultDetails.nocache,
|
|
1758
1760
|
revalidate: details.revalidate || this.context.#defaultDetails.revalidate,
|
|
@@ -1854,6 +1856,15 @@ class Httpx {
|
|
|
1854
1856
|
else {
|
|
1855
1857
|
result.fetchInit = details.fetchInit;
|
|
1856
1858
|
}
|
|
1859
|
+
// 处理新的cookiePartition
|
|
1860
|
+
if (typeof result.cookiePartition === "object" &&
|
|
1861
|
+
result.cookiePartition != null) {
|
|
1862
|
+
if (Reflect.has(result.cookiePartition, "topLevelSite") &&
|
|
1863
|
+
typeof result.cookiePartition.topLevelSite !== "string") {
|
|
1864
|
+
// topLevelSite必须是字符串
|
|
1865
|
+
Reflect.deleteProperty(result.cookiePartition, "topLevelSite");
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1857
1868
|
return result;
|
|
1858
1869
|
},
|
|
1859
1870
|
/**
|
|
@@ -2343,6 +2354,7 @@ class Httpx {
|
|
|
2343
2354
|
data: void 0,
|
|
2344
2355
|
redirect: void 0,
|
|
2345
2356
|
cookie: void 0,
|
|
2357
|
+
cookiePartition: void 0,
|
|
2346
2358
|
binary: void 0,
|
|
2347
2359
|
nocache: void 0,
|
|
2348
2360
|
revalidate: void 0,
|
|
@@ -3926,7 +3938,7 @@ class Utils {
|
|
|
3926
3938
|
this.windowApi = new WindowApi(option);
|
|
3927
3939
|
}
|
|
3928
3940
|
/** 版本号 */
|
|
3929
|
-
version = "2024.9.
|
|
3941
|
+
version = "2024.9.28";
|
|
3930
3942
|
addStyle(cssText) {
|
|
3931
3943
|
if (typeof cssText !== "string") {
|
|
3932
3944
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -6439,13 +6451,29 @@ class Utils {
|
|
|
6439
6451
|
* > ()=>{throw new Error('测试错误')}出现错误
|
|
6440
6452
|
*/
|
|
6441
6453
|
tryCatch = TryCatch;
|
|
6442
|
-
uniqueArray(uniqueArrayData = [], compareArrayData
|
|
6443
|
-
// @ts-ignore
|
|
6454
|
+
uniqueArray(uniqueArrayData = [], compareArrayData, compareFun = (item, item2) => {
|
|
6444
6455
|
return item === item2;
|
|
6445
6456
|
}) {
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6457
|
+
if (typeof compareArrayData === "function") {
|
|
6458
|
+
const compareFn = compareArrayData;
|
|
6459
|
+
const seen = new Set();
|
|
6460
|
+
const result = [];
|
|
6461
|
+
for (const item of uniqueArrayData) {
|
|
6462
|
+
// 使用compareFn函数来获取当前对象的唯一标识
|
|
6463
|
+
const identfier = compareFn(item);
|
|
6464
|
+
// 如果Set中还没有这个标识,则添加到结果数组中,并将其标识存入Set
|
|
6465
|
+
if (!seen.has(identfier)) {
|
|
6466
|
+
seen.add(identfier);
|
|
6467
|
+
result.push(item);
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
return result;
|
|
6471
|
+
}
|
|
6472
|
+
else {
|
|
6473
|
+
return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
|
|
6474
|
+
return compareFun(item, item2);
|
|
6475
|
+
}));
|
|
6476
|
+
}
|
|
6449
6477
|
}
|
|
6450
6478
|
waitArrayLoopToEnd(data, handleFunc) {
|
|
6451
6479
|
let UtilsContext = this;
|