@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 CHANGED
@@ -1755,6 +1755,8 @@ define((function () { 'use strict';
1755
1755
  data: details.data || this.context.#defaultDetails.data,
1756
1756
  redirect: details.redirect || this.context.#defaultDetails.redirect,
1757
1757
  cookie: details.cookie || this.context.#defaultDetails.cookie,
1758
+ cookiePartition: details.cookiePartition ||
1759
+ this.context.#defaultDetails.cookiePartition,
1758
1760
  binary: details.binary || this.context.#defaultDetails.binary,
1759
1761
  nocache: details.nocache || this.context.#defaultDetails.nocache,
1760
1762
  revalidate: details.revalidate || this.context.#defaultDetails.revalidate,
@@ -1856,6 +1858,15 @@ define((function () { 'use strict';
1856
1858
  else {
1857
1859
  result.fetchInit = details.fetchInit;
1858
1860
  }
1861
+ // 处理新的cookiePartition
1862
+ if (typeof result.cookiePartition === "object" &&
1863
+ result.cookiePartition != null) {
1864
+ if (Reflect.has(result.cookiePartition, "topLevelSite") &&
1865
+ typeof result.cookiePartition.topLevelSite !== "string") {
1866
+ // topLevelSite必须是字符串
1867
+ Reflect.deleteProperty(result.cookiePartition, "topLevelSite");
1868
+ }
1869
+ }
1859
1870
  return result;
1860
1871
  },
1861
1872
  /**
@@ -2345,6 +2356,7 @@ define((function () { 'use strict';
2345
2356
  data: void 0,
2346
2357
  redirect: void 0,
2347
2358
  cookie: void 0,
2359
+ cookiePartition: void 0,
2348
2360
  binary: void 0,
2349
2361
  nocache: void 0,
2350
2362
  revalidate: void 0,
@@ -3928,7 +3940,7 @@ define((function () { 'use strict';
3928
3940
  this.windowApi = new WindowApi(option);
3929
3941
  }
3930
3942
  /** 版本号 */
3931
- version = "2024.9.10";
3943
+ version = "2024.9.28";
3932
3944
  addStyle(cssText) {
3933
3945
  if (typeof cssText !== "string") {
3934
3946
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -6441,13 +6453,29 @@ define((function () { 'use strict';
6441
6453
  * > ()=>{throw new Error('测试错误')}出现错误
6442
6454
  */
6443
6455
  tryCatch = TryCatch;
6444
- uniqueArray(uniqueArrayData = [], compareArrayData = [], compareFun = (item, item2) => {
6445
- // @ts-ignore
6456
+ uniqueArray(uniqueArrayData = [], compareArrayData, compareFun = (item, item2) => {
6446
6457
  return item === item2;
6447
6458
  }) {
6448
- return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
6449
- return compareFun(item, item2);
6450
- }));
6459
+ if (typeof compareArrayData === "function") {
6460
+ const compareFn = compareArrayData;
6461
+ const seen = new Set();
6462
+ const result = [];
6463
+ for (const item of uniqueArrayData) {
6464
+ // 使用compareFn函数来获取当前对象的唯一标识
6465
+ const identfier = compareFn(item);
6466
+ // 如果Set中还没有这个标识,则添加到结果数组中,并将其标识存入Set
6467
+ if (!seen.has(identfier)) {
6468
+ seen.add(identfier);
6469
+ result.push(item);
6470
+ }
6471
+ }
6472
+ return result;
6473
+ }
6474
+ else {
6475
+ return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
6476
+ return compareFun(item, item2);
6477
+ }));
6478
+ }
6451
6479
  }
6452
6480
  waitArrayLoopToEnd(data, handleFunc) {
6453
6481
  let UtilsContext = this;