@whitesev/utils 2.3.1 → 2.3.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.
- package/dist/index.amd.js +21 -5
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +21 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +21 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +21 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +21 -5
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +21 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +9 -0
- package/package.json +1 -1
- package/src/Utils.ts +38 -10
package/dist/index.iife.js
CHANGED
|
@@ -6442,13 +6442,29 @@ var Utils = (function () {
|
|
|
6442
6442
|
* > ()=>{throw new Error('测试错误')}出现错误
|
|
6443
6443
|
*/
|
|
6444
6444
|
tryCatch = TryCatch;
|
|
6445
|
-
uniqueArray(uniqueArrayData = [], compareArrayData
|
|
6446
|
-
// @ts-ignore
|
|
6445
|
+
uniqueArray(uniqueArrayData = [], compareArrayData, compareFun = (item, item2) => {
|
|
6447
6446
|
return item === item2;
|
|
6448
6447
|
}) {
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6448
|
+
if (typeof compareArrayData === "function") {
|
|
6449
|
+
const compareFn = compareArrayData;
|
|
6450
|
+
const seen = new Set();
|
|
6451
|
+
const result = [];
|
|
6452
|
+
for (const item of uniqueArrayData) {
|
|
6453
|
+
// 使用compareFn函数来获取当前对象的唯一标识
|
|
6454
|
+
const identfier = compareFn(item);
|
|
6455
|
+
// 如果Set中还没有这个标识,则添加到结果数组中,并将其标识存入Set
|
|
6456
|
+
if (!seen.has(identfier)) {
|
|
6457
|
+
seen.add(identfier);
|
|
6458
|
+
result.push(item);
|
|
6459
|
+
}
|
|
6460
|
+
}
|
|
6461
|
+
return result;
|
|
6462
|
+
}
|
|
6463
|
+
else {
|
|
6464
|
+
return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
|
|
6465
|
+
return compareFun(item, item2);
|
|
6466
|
+
}));
|
|
6467
|
+
}
|
|
6452
6468
|
}
|
|
6453
6469
|
waitArrayLoopToEnd(data, handleFunc) {
|
|
6454
6470
|
let UtilsContext = this;
|