@fast-china/utils 1.0.17 → 1.0.19
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.global.js +28 -8
- package/dist/index.global.js.map +1 -1
- package/dist/index.global.min.js +5 -5
- package/dist/index.global.min.js.map +1 -1
- package/es/array/index.d.ts +2 -2
- package/es/array/index.mjs +28 -8
- package/es/array/index.mjs.map +1 -1
- package/lib/array/index.d.ts +2 -2
- package/lib/array/index.js +1 -1
- package/lib/array/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -8,9 +8,23 @@ var FastUtils = function(exports, vue) {
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
hasDuplicateProperty(arr, prop) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (Array.isArray(prop)) {
|
|
12
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13
|
+
for (const obj of arr) {
|
|
14
|
+
const key = JSON.stringify(prop.map((p) => obj[p]));
|
|
15
|
+
if (seen.has(key)) return true;
|
|
16
|
+
seen.add(key);
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
} else {
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
for (const obj of arr) {
|
|
22
|
+
const value = obj[prop];
|
|
23
|
+
if (seen.has(value)) return true;
|
|
24
|
+
seen.add(value);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
14
28
|
},
|
|
15
29
|
/**
|
|
16
30
|
* 是否存在非重复值
|
|
@@ -19,11 +33,17 @@ var FastUtils = function(exports, vue) {
|
|
|
19
33
|
* @returns
|
|
20
34
|
*/
|
|
21
35
|
hasDifferentProperty(arr, prop) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
if (arr.length <= 1) return false;
|
|
37
|
+
if (Array.isArray(prop)) {
|
|
38
|
+
const firstKey = JSON.stringify(prop.map((p) => arr[0][p]));
|
|
39
|
+
for (let i = 1; i < arr.length; i++) {
|
|
40
|
+
const currentKey = JSON.stringify(prop.map((p) => arr[i][p]));
|
|
41
|
+
if (currentKey !== firstKey) return true;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const firstValue = arr[0][prop];
|
|
45
|
+
for (let i = 1; i < arr.length; i++) {
|
|
46
|
+
if (arr[i][prop] !== firstValue) return true;
|
|
27
47
|
}
|
|
28
48
|
}
|
|
29
49
|
return false;
|