@fast-china/utils 1.0.16 → 1.0.18
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/README.md +15 -9
- package/README.zh.md +15 -9
- 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 +3 -3
package/es/array/index.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ export declare const arrayUtil: {
|
|
|
8
8
|
* @param prop 属性
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
|
-
hasDuplicateProperty<T>(arr: T[], prop: keyof T): boolean;
|
|
11
|
+
hasDuplicateProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean;
|
|
12
12
|
/**
|
|
13
13
|
* 是否存在非重复值
|
|
14
14
|
* @param arr 数组
|
|
15
15
|
* @param prop 属性
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
hasDifferentProperty<T>(arr: T[], prop: keyof T): boolean;
|
|
18
|
+
hasDifferentProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean;
|
|
19
19
|
};
|
package/es/array/index.mjs
CHANGED
|
@@ -6,9 +6,23 @@ const arrayUtil = {
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
hasDuplicateProperty(arr, prop) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (Array.isArray(prop)) {
|
|
10
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11
|
+
for (const obj of arr) {
|
|
12
|
+
const key = JSON.stringify(prop.map((p) => obj[p]));
|
|
13
|
+
if (seen.has(key)) return true;
|
|
14
|
+
seen.add(key);
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
} else {
|
|
18
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19
|
+
for (const obj of arr) {
|
|
20
|
+
const value = obj[prop];
|
|
21
|
+
if (seen.has(value)) return true;
|
|
22
|
+
seen.add(value);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
12
26
|
},
|
|
13
27
|
/**
|
|
14
28
|
* 是否存在非重复值
|
|
@@ -17,11 +31,17 @@ const arrayUtil = {
|
|
|
17
31
|
* @returns
|
|
18
32
|
*/
|
|
19
33
|
hasDifferentProperty(arr, prop) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
if (arr.length <= 1) return false;
|
|
35
|
+
if (Array.isArray(prop)) {
|
|
36
|
+
const firstKey = JSON.stringify(prop.map((p) => arr[0][p]));
|
|
37
|
+
for (let i = 1; i < arr.length; i++) {
|
|
38
|
+
const currentKey = JSON.stringify(prop.map((p) => arr[i][p]));
|
|
39
|
+
if (currentKey !== firstKey) return true;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
const firstValue = arr[0][prop];
|
|
43
|
+
for (let i = 1; i < arr.length; i++) {
|
|
44
|
+
if (arr[i][prop] !== firstValue) return true;
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
47
|
return false;
|
package/es/array/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/array/index.ts"],"sourcesContent":["/**\n * 数据工具类\n */\nexport const arrayUtil = {\n\t/**\n\t * 是否存在重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDuplicateProperty<T>(arr: T[], prop: keyof T): boolean {\n\t\tconst
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/array/index.ts"],"sourcesContent":["/**\n * 数据工具类\n */\nexport const arrayUtil = {\n\t/**\n\t * 是否存在重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDuplicateProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean {\n\t\tif (Array.isArray(prop)) {\n\t\t\tconst seen = new Set<string>();\n\t\t\tfor (const obj of arr) {\n\t\t\t\tconst key = JSON.stringify(prop.map((p) => obj[p]));\n\t\t\t\tif (seen.has(key)) return true;\n\t\t\t\tseen.add(key);\n\t\t\t}\n\t\t\treturn false;\n\t\t} else {\n\t\t\tconst seen = new Set<any>();\n\t\t\tfor (const obj of arr) {\n\t\t\t\tconst value = obj[prop];\n\t\t\t\tif (seen.has(value)) return true;\n\t\t\t\tseen.add(value);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t},\n\t/**\n\t * 是否存在非重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDifferentProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean {\n\t\tif (arr.length <= 1) return false;\n\n\t\tif (Array.isArray(prop)) {\n\t\t\tconst firstKey = JSON.stringify(prop.map((p) => arr[0][p]));\n\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\tconst currentKey = JSON.stringify(prop.map((p) => arr[i][p]));\n\t\t\t\tif (currentKey !== firstKey) return true;\n\t\t\t}\n\t\t} else {\n\t\t\tconst firstValue = arr[0][prop];\n\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i][prop] !== firstValue) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t},\n};\n"],"names":[],"mappings":"AAGO,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,qBAAwB,KAAU,MAAsC;AACnE,QAAA,MAAM,QAAQ,IAAI,GAAG;AAClB,YAAA,2BAAW,IAAY;AAC7B,iBAAW,OAAO,KAAK;AAChB,cAAA,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAClD,YAAI,KAAK,IAAI,GAAG,EAAU,QAAA;AAC1B,aAAK,IAAI,GAAG;AAAA,MAAA;AAEN,aAAA;AAAA,IAAA,OACD;AACA,YAAA,2BAAW,IAAS;AAC1B,iBAAW,OAAO,KAAK;AAChB,cAAA,QAAQ,IAAI,IAAI;AACtB,YAAI,KAAK,IAAI,KAAK,EAAU,QAAA;AAC5B,aAAK,IAAI,KAAK;AAAA,MAAA;AAER,aAAA;AAAA,IAAA;AAAA,EAET;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,qBAAwB,KAAU,MAAsC;AACnE,QAAA,IAAI,UAAU,EAAU,QAAA;AAExB,QAAA,MAAM,QAAQ,IAAI,GAAG;AACxB,YAAM,WAAW,KAAK,UAAU,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1D,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACpC,cAAM,aAAa,KAAK,UAAU,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,YAAA,eAAe,SAAiB,QAAA;AAAA,MAAA;AAAA,IACrC,OACM;AACN,YAAM,aAAa,IAAI,CAAC,EAAE,IAAI;AAC9B,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACpC,YAAI,IAAI,CAAC,EAAE,IAAI,MAAM,WAAmB,QAAA;AAAA,MAAA;AAAA,IACzC;AAEM,WAAA;AAAA,EAAA;AAET;"}
|
package/lib/array/index.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ export declare const arrayUtil: {
|
|
|
8
8
|
* @param prop 属性
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
|
-
hasDuplicateProperty<T>(arr: T[], prop: keyof T): boolean;
|
|
11
|
+
hasDuplicateProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean;
|
|
12
12
|
/**
|
|
13
13
|
* 是否存在非重复值
|
|
14
14
|
* @param arr 数组
|
|
15
15
|
* @param prop 属性
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
hasDifferentProperty<T>(arr: T[], prop: keyof T): boolean;
|
|
18
|
+
hasDifferentProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean;
|
|
19
19
|
};
|
package/lib/array/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={hasDuplicateProperty(r,t){if(Array.isArray(t)){const e=new Set;for(const n of r){const r=JSON.stringify(t.map((r=>n[r])));if(e.has(r))return!0;e.add(r)}return!1}{const e=new Set;for(const n of r){const r=n[t];if(e.has(r))return!0;e.add(r)}return!1}},hasDifferentProperty(r,t){if(r.length<=1)return!1;if(Array.isArray(t)){const e=JSON.stringify(t.map((t=>r[0][t])));for(let n=1;n<r.length;n++){if(JSON.stringify(t.map((t=>r[n][t])))!==e)return!0}}else{const e=r[0][t];for(let n=1;n<r.length;n++)if(r[n][t]!==e)return!0}return!1}};exports.arrayUtil=r;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/array/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/array/index.ts"],"sourcesContent":["/**\n * 数据工具类\n */\nexport const arrayUtil = {\n\t/**\n\t * 是否存在重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDuplicateProperty<T>(arr: T[], prop: keyof T): boolean {\n\t\tconst
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/array/index.ts"],"sourcesContent":["/**\n * 数据工具类\n */\nexport const arrayUtil = {\n\t/**\n\t * 是否存在重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDuplicateProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean {\n\t\tif (Array.isArray(prop)) {\n\t\t\tconst seen = new Set<string>();\n\t\t\tfor (const obj of arr) {\n\t\t\t\tconst key = JSON.stringify(prop.map((p) => obj[p]));\n\t\t\t\tif (seen.has(key)) return true;\n\t\t\t\tseen.add(key);\n\t\t\t}\n\t\t\treturn false;\n\t\t} else {\n\t\t\tconst seen = new Set<any>();\n\t\t\tfor (const obj of arr) {\n\t\t\t\tconst value = obj[prop];\n\t\t\t\tif (seen.has(value)) return true;\n\t\t\t\tseen.add(value);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t},\n\t/**\n\t * 是否存在非重复值\n\t * @param arr 数组\n\t * @param prop 属性\n\t * @returns\n\t */\n\thasDifferentProperty<T>(arr: T[], prop: keyof T | (keyof T)[]): boolean {\n\t\tif (arr.length <= 1) return false;\n\n\t\tif (Array.isArray(prop)) {\n\t\t\tconst firstKey = JSON.stringify(prop.map((p) => arr[0][p]));\n\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\tconst currentKey = JSON.stringify(prop.map((p) => arr[i][p]));\n\t\t\t\tif (currentKey !== firstKey) return true;\n\t\t\t}\n\t\t} else {\n\t\t\tconst firstValue = arr[0][prop];\n\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\tif (arr[i][prop] !== firstValue) return true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t},\n};\n"],"names":["arrayUtil","hasDuplicateProperty","arr","prop","Array","isArray","seen","Set","obj","key","JSON","stringify","map","p","has","add","value","hasDifferentProperty","length","firstKey","i","firstValue"],"mappings":"gFAGO,MAAMA,EAAY,CAOxB,oBAAAC,CAAwBC,EAAUC,GAC7B,GAAAC,MAAMC,QAAQF,GAAO,CAClB,MAAAG,MAAWC,IACjB,IAAA,MAAWC,KAAON,EAAK,CAChB,MAAAO,EAAMC,KAAKC,UAAUR,EAAKS,KAAKC,GAAML,EAAIK,MAC/C,GAAIP,EAAKQ,IAAIL,GAAa,OAAA,EAC1BH,EAAKS,IAAIN,EAAG,CAEN,OAAA,CAAA,CACD,CACA,MAAAH,MAAWC,IACjB,IAAA,MAAWC,KAAON,EAAK,CAChB,MAAAc,EAAQR,EAAIL,GAClB,GAAIG,EAAKQ,IAAIE,GAAe,OAAA,EAC5BV,EAAKS,IAAIC,EAAK,CAER,OAAA,CAAA,CAET,EAOA,oBAAAC,CAAwBf,EAAUC,GAC7B,GAAAD,EAAIgB,QAAU,EAAU,OAAA,EAExB,GAAAd,MAAMC,QAAQF,GAAO,CACxB,MAAMgB,EAAWT,KAAKC,UAAUR,EAAKS,KAAKC,GAAMX,EAAI,GAAGW,MACvD,IAAA,IAASO,EAAI,EAAGA,EAAIlB,EAAIgB,OAAQE,IAAK,CAEhC,GADeV,KAAKC,UAAUR,EAAKS,KAAKC,GAAMX,EAAIkB,GAAGP,QACtCM,EAAiB,OAAA,CAAA,CACrC,KACM,CACN,MAAME,EAAanB,EAAI,GAAGC,GAC1B,IAAA,IAASiB,EAAI,EAAGA,EAAIlB,EAAIgB,OAAQE,IAC/B,GAAIlB,EAAIkB,GAAGjB,KAAUkB,EAAmB,OAAA,CACzC,CAEM,OAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fast-china/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Fast 工具库.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"vue": "^3
|
|
78
|
+
"vue": "^2 || ^3"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@types/crypto-js": "^4.2.0",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@dcloudio/types": "latest",
|
|
91
91
|
"@types/node": "latest",
|
|
92
|
-
"vue": "^3
|
|
92
|
+
"vue": "^2 || ^3"
|
|
93
93
|
}
|
|
94
94
|
}
|