@fangzhongya/utils 0.0.5 → 0.0.6-1

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.
Files changed (83) hide show
  1. package/dist/basic/array/index.cjs +3 -3
  2. package/dist/basic/array/index.js +4 -4
  3. package/dist/basic/index.cjs +11 -9
  4. package/dist/basic/index.d.ts +5 -3
  5. package/dist/basic/index.js +12 -10
  6. package/dist/basic/object/index.cjs +4 -4
  7. package/dist/basic/object/index.d.ts +2 -1
  8. package/dist/basic/object/index.js +5 -5
  9. package/dist/basic/object/mergeObject.cjs +2 -6
  10. package/dist/basic/object/mergeObject.d.ts +1 -19
  11. package/dist/basic/object/mergeObject.js +3 -7
  12. package/dist/basic/object/unmergeObject.cjs +7 -0
  13. package/dist/basic/object/unmergeObject.d.ts +11 -0
  14. package/dist/basic/object/unmergeObject.js +7 -0
  15. package/dist/basic/string/firstLower.cjs +7 -0
  16. package/dist/basic/string/firstLower.d.ts +8 -0
  17. package/dist/basic/string/firstLower.js +7 -0
  18. package/dist/basic/string/firstUpper.cjs +7 -0
  19. package/dist/basic/string/firstUpper.d.ts +8 -0
  20. package/dist/basic/string/firstUpper.js +7 -0
  21. package/dist/basic/string/index.cjs +4 -4
  22. package/dist/basic/string/index.d.ts +2 -1
  23. package/dist/basic/string/index.js +7 -7
  24. package/dist/chunk-2B742V22.cjs +19 -0
  25. package/dist/chunk-2PY55D6T.js +16 -0
  26. package/dist/{chunk-P33DGEQL.js → chunk-34IFL7OR.js} +5 -5
  27. package/dist/chunk-3OME5O5G.cjs +16 -0
  28. package/dist/chunk-3VYRYSWK.cjs +49 -0
  29. package/dist/chunk-3YPXLIH5.js +21 -0
  30. package/dist/chunk-4OBNLDTJ.js +8 -0
  31. package/dist/chunk-A6J46LQK.js +49 -0
  32. package/dist/{chunk-4PBAZ73I.cjs → chunk-AH7GPXDD.cjs} +4 -4
  33. package/dist/{chunk-ED5PJTG5.js → chunk-AP2GHAT5.js} +3 -3
  34. package/dist/chunk-BRNROSJJ.cjs +24 -0
  35. package/dist/chunk-EWJJKQIO.js +8 -0
  36. package/dist/{chunk-JNC5JEFB.cjs → chunk-FXMA7ZCM.cjs} +2 -2
  37. package/dist/{chunk-DEENZC5X.js → chunk-J7CICTHH.js} +3 -11
  38. package/dist/{chunk-BEQYORII.cjs → chunk-LTVXRDTD.cjs} +3 -11
  39. package/dist/{chunk-AZNBYC7K.js → chunk-MAIGGOA4.js} +4 -4
  40. package/dist/chunk-NRJPCN4J.cjs +46 -0
  41. package/dist/chunk-O3RJ5M35.js +19 -0
  42. package/dist/chunk-OC2MRJDZ.cjs +21 -0
  43. package/dist/chunk-OQL4GIEJ.cjs +8 -0
  44. package/dist/{chunk-YYNHNLVW.js → chunk-PPEJX3ZH.js} +6 -6
  45. package/dist/{chunk-YZULJRHH.cjs → chunk-R7G5MSGO.cjs} +4 -4
  46. package/dist/chunk-RD4EP3M5.js +46 -0
  47. package/dist/chunk-S7VMX72B.cjs +32 -0
  48. package/dist/chunk-TRLNJ6BO.cjs +38 -0
  49. package/dist/chunk-UEVMS6QD.cjs +8 -0
  50. package/dist/chunk-W7OSG6B2.js +32 -0
  51. package/dist/chunk-YHBKZTYZ.js +38 -0
  52. package/dist/{index-8abebe13.d.ts → index-0cc6b278.d.ts} +2 -2
  53. package/dist/{index-5c5bf158.d.ts → index-3062a21e.d.ts} +2 -3
  54. package/dist/{index-5691335a.d.ts → index-8925a102.d.ts} +2 -3
  55. package/dist/index-f9cc2ca2.d.ts +22 -0
  56. package/dist/index.cjs +20 -9
  57. package/dist/index.d.ts +13 -5
  58. package/dist/index.js +20 -9
  59. package/dist/name/getComponentNames.cjs +12 -0
  60. package/dist/name/getComponentNames.d.ts +8 -0
  61. package/dist/name/getComponentNames.js +12 -0
  62. package/dist/name/getNames.cjs +12 -0
  63. package/dist/name/getNames.d.ts +8 -0
  64. package/dist/name/getNames.js +12 -0
  65. package/dist/name/humpToLine.cjs +7 -0
  66. package/dist/name/humpToLine.d.ts +8 -0
  67. package/dist/name/humpToLine.js +7 -0
  68. package/dist/name/index.cjs +26 -0
  69. package/dist/name/index.d.ts +5 -0
  70. package/dist/name/index.js +26 -0
  71. package/dist/name/lineToLargeHump.cjs +8 -0
  72. package/dist/name/lineToLargeHump.d.ts +8 -0
  73. package/dist/name/lineToLargeHump.js +8 -0
  74. package/dist/name/lineToSmallHump.cjs +9 -0
  75. package/dist/name/lineToSmallHump.d.ts +8 -0
  76. package/dist/name/lineToSmallHump.js +9 -0
  77. package/package.json +70 -25
  78. package/dist/basic/string/index2.cjs +0 -11
  79. package/dist/basic/string/index2.d.ts +0 -20
  80. package/dist/basic/string/index2.js +0 -11
  81. package/dist/chunk-J53DPBUN.cjs +0 -24
  82. package/dist/chunk-LYFX6BGT.js +0 -129
  83. package/dist/chunk-VAYHA5HS.cjs +0 -129
@@ -0,0 +1,12 @@
1
+ import {
2
+ getNames
3
+ } from "../chunk-3YPXLIH5.js";
4
+ import "../chunk-2PY55D6T.js";
5
+ import "../chunk-O3RJ5M35.js";
6
+ import "../chunk-EWJJKQIO.js";
7
+ import "../chunk-4OBNLDTJ.js";
8
+ import "../chunk-J7CICTHH.js";
9
+ import "../chunk-UICA3PK6.js";
10
+ export {
11
+ getNames
12
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkLTVXRDTDcjs = require('../chunk-LTVXRDTD.cjs');
4
+ require('../chunk-5AZGAKWR.cjs');
5
+
6
+
7
+ exports.humpToLine = _chunkLTVXRDTDcjs.humpToLine;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 驼峰命名转 - 方式
3
+ * @param {*} name
4
+ * @returns
5
+ */
6
+ declare function humpToLine(name: string): string;
7
+
8
+ export { humpToLine };
@@ -0,0 +1,7 @@
1
+ import {
2
+ humpToLine
3
+ } from "../chunk-J7CICTHH.js";
4
+ import "../chunk-UICA3PK6.js";
5
+ export {
6
+ humpToLine
7
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-S7VMX72B.cjs');
2
+
3
+
4
+ var _chunkTRLNJ6BOcjs = require('../chunk-TRLNJ6BO.cjs');
5
+
6
+
7
+ var _chunkOC2MRJDZcjs = require('../chunk-OC2MRJDZ.cjs');
8
+
9
+
10
+ var _chunk3OME5O5Gcjs = require('../chunk-3OME5O5G.cjs');
11
+
12
+
13
+ var _chunk2B742V22cjs = require('../chunk-2B742V22.cjs');
14
+ require('../chunk-OQL4GIEJ.cjs');
15
+ require('../chunk-UEVMS6QD.cjs');
16
+
17
+
18
+ var _chunkLTVXRDTDcjs = require('../chunk-LTVXRDTD.cjs');
19
+ require('../chunk-5AZGAKWR.cjs');
20
+
21
+
22
+
23
+
24
+
25
+
26
+ exports.getComponentNames = _chunkTRLNJ6BOcjs.getComponentNames; exports.getNames = _chunkOC2MRJDZcjs.getNames; exports.humpToLine = _chunkLTVXRDTDcjs.humpToLine; exports.lineToLargeHump = _chunk3OME5O5Gcjs.lineToLargeHump; exports.lineToSmallHump = _chunk2B742V22cjs.lineToSmallHump;
@@ -0,0 +1,5 @@
1
+ export { getNames } from './getNames.js';
2
+ export { getComponentNames } from './getComponentNames.js';
3
+ export { humpToLine } from './humpToLine.js';
4
+ export { lineToLargeHump } from './lineToLargeHump.js';
5
+ export { lineToSmallHump } from './lineToSmallHump.js';
@@ -0,0 +1,26 @@
1
+ import "../chunk-W7OSG6B2.js";
2
+ import {
3
+ getComponentNames
4
+ } from "../chunk-YHBKZTYZ.js";
5
+ import {
6
+ getNames
7
+ } from "../chunk-3YPXLIH5.js";
8
+ import {
9
+ lineToLargeHump
10
+ } from "../chunk-2PY55D6T.js";
11
+ import {
12
+ lineToSmallHump
13
+ } from "../chunk-O3RJ5M35.js";
14
+ import "../chunk-EWJJKQIO.js";
15
+ import "../chunk-4OBNLDTJ.js";
16
+ import {
17
+ humpToLine
18
+ } from "../chunk-J7CICTHH.js";
19
+ import "../chunk-UICA3PK6.js";
20
+ export {
21
+ getComponentNames,
22
+ getNames,
23
+ humpToLine,
24
+ lineToLargeHump,
25
+ lineToSmallHump
26
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk3OME5O5Gcjs = require('../chunk-3OME5O5G.cjs');
4
+ require('../chunk-UEVMS6QD.cjs');
5
+ require('../chunk-5AZGAKWR.cjs');
6
+
7
+
8
+ exports.lineToLargeHump = _chunk3OME5O5Gcjs.lineToLargeHump;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * - 方式 转 大驼峰命名
3
+ * @param name
4
+ * @returns
5
+ */
6
+ declare function lineToLargeHump(name: string): string;
7
+
8
+ export { lineToLargeHump };
@@ -0,0 +1,8 @@
1
+ import {
2
+ lineToLargeHump
3
+ } from "../chunk-2PY55D6T.js";
4
+ import "../chunk-4OBNLDTJ.js";
5
+ import "../chunk-UICA3PK6.js";
6
+ export {
7
+ lineToLargeHump
8
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk2B742V22cjs = require('../chunk-2B742V22.cjs');
4
+ require('../chunk-OQL4GIEJ.cjs');
5
+ require('../chunk-UEVMS6QD.cjs');
6
+ require('../chunk-5AZGAKWR.cjs');
7
+
8
+
9
+ exports.lineToSmallHump = _chunk2B742V22cjs.lineToSmallHump;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * - 方式 转 小驼峰
3
+ * @param name
4
+ * @returns
5
+ */
6
+ declare function lineToSmallHump(name: string): string;
7
+
8
+ export { lineToSmallHump };
@@ -0,0 +1,9 @@
1
+ import {
2
+ lineToSmallHump
3
+ } from "../chunk-O3RJ5M35.js";
4
+ import "../chunk-EWJJKQIO.js";
5
+ import "../chunk-4OBNLDTJ.js";
6
+ import "../chunk-UICA3PK6.js";
7
+ export {
8
+ lineToSmallHump
9
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fangzhongya/utils",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.0.5",
5
+ "version": "0.0.6-1",
6
6
  "description ": "个人工具库",
7
7
  "author": "fangzhongya ",
8
8
  "license": "MIT",
@@ -23,15 +23,12 @@
23
23
  "test": "vitest test"
24
24
  },
25
25
  "devDependencies": {
26
- "@fangzhongya/create": "^0.1.0",
27
- "@types/node": "^18.11.18",
26
+ "@fangzhongya/create": "0.1.9",
27
+ "@types/node": "^18.11.19",
28
28
  "tsup": "^6.5.0",
29
29
  "typescript": "^4.9.5",
30
30
  "vitest": "^0.28.4"
31
31
  },
32
- "main": "./dist/index.cjs",
33
- "module": "./dist/index.js",
34
- "types": "./dist/index.d.ts",
35
32
  "typesVersions": {
36
33
  "*": {
37
34
  "*": [
@@ -43,11 +40,6 @@
43
40
  "dist"
44
41
  ],
45
42
  "exports": {
46
- ".": {
47
- "require": "./dist/index.cjs",
48
- "import": "./dist/index.js",
49
- "types": "./dist/index.d.ts"
50
- },
51
43
  "./basic/array": {
52
44
  "require": "./dist/basic/array/index.cjs",
53
45
  "import": "./dist/basic/array/index.js",
@@ -68,40 +60,93 @@
68
60
  "import": "./dist/basic/object/index.js",
69
61
  "types": "./dist/basic/object/index.d.ts"
70
62
  },
63
+ "./basic/object/isObject": {
64
+ "require": "./dist/basic/object/isObject.cjs",
65
+ "import": "./dist/basic/object/isObject.js",
66
+ "types": "./dist/basic/object/isObject.d.ts"
67
+ },
71
68
  "./basic/object/mergeObject": {
72
69
  "require": "./dist/basic/object/mergeObject.cjs",
73
70
  "import": "./dist/basic/object/mergeObject.js",
74
71
  "types": "./dist/basic/object/mergeObject.d.ts"
75
72
  },
76
- "./basic/object/isObject": {
77
- "require": "./dist/basic/object/isObject.cjs",
78
- "import": "./dist/basic/object/isObject.js",
79
- "types": "./dist/basic/object/isObject.d.ts"
73
+ "./basic/object/unmergeObject": {
74
+ "require": "./dist/basic/object/unmergeObject.cjs",
75
+ "import": "./dist/basic/object/unmergeObject.js",
76
+ "types": "./dist/basic/object/unmergeObject.d.ts"
80
77
  },
81
78
  "./basic/string": {
82
79
  "require": "./dist/basic/string/index.cjs",
83
80
  "import": "./dist/basic/string/index.js",
84
81
  "types": "./dist/basic/string/index.d.ts"
85
82
  },
86
- "./basic/string/index2": {
87
- "require": "./dist/basic/string/index2.cjs",
88
- "import": "./dist/basic/string/index2.js",
89
- "types": "./dist/basic/string/index2.d.ts"
90
- },
91
83
  "./basic": {
92
84
  "require": "./dist/basic/index.cjs",
93
85
  "import": "./dist/basic/index.js",
94
86
  "types": "./dist/basic/index.d.ts"
95
87
  },
96
- "./iss": {
97
- "require": "./dist/iss/index.cjs",
98
- "import": "./dist/iss/index.js",
99
- "types": "./dist/iss/index.d.ts"
88
+ "./log": {
89
+ "require": "./dist/log/index.cjs",
90
+ "import": "./dist/log/index.js",
91
+ "types": "./dist/log/index.d.ts"
100
92
  },
101
93
  "./log/styleLog": {
102
94
  "require": "./dist/log/styleLog.cjs",
103
95
  "import": "./dist/log/styleLog.js",
104
96
  "types": "./dist/log/styleLog.d.ts"
97
+ },
98
+ "./iss": {
99
+ "require": "./dist/iss/index.cjs",
100
+ "import": "./dist/iss/index.js",
101
+ "types": "./dist/iss/index.d.ts"
102
+ },
103
+ ".": {
104
+ "require": "./dist/index.cjs",
105
+ "import": "./dist/index.js",
106
+ "types": "./dist/index.d.ts"
107
+ },
108
+ "./basic/string/firstLower": {
109
+ "require": "./dist/basic/string/firstLower.cjs",
110
+ "import": "./dist/basic/string/firstLower.js",
111
+ "types": "./dist/basic/string/firstLower.d.ts"
112
+ },
113
+ "./basic/string/firstUpper": {
114
+ "require": "./dist/basic/string/firstUpper.cjs",
115
+ "import": "./dist/basic/string/firstUpper.js",
116
+ "types": "./dist/basic/string/firstUpper.d.ts"
117
+ },
118
+ "./name/getComponentNames": {
119
+ "require": "./dist/name/getComponentNames.cjs",
120
+ "import": "./dist/name/getComponentNames.js",
121
+ "types": "./dist/name/getComponentNames.d.ts"
122
+ },
123
+ "./name/getNames": {
124
+ "require": "./dist/name/getNames.cjs",
125
+ "import": "./dist/name/getNames.js",
126
+ "types": "./dist/name/getNames.d.ts"
127
+ },
128
+ "./name/humpToLine": {
129
+ "require": "./dist/name/humpToLine.cjs",
130
+ "import": "./dist/name/humpToLine.js",
131
+ "types": "./dist/name/humpToLine.d.ts"
132
+ },
133
+ "./name/lineToLargeHump": {
134
+ "require": "./dist/name/lineToLargeHump.cjs",
135
+ "import": "./dist/name/lineToLargeHump.js",
136
+ "types": "./dist/name/lineToLargeHump.d.ts"
137
+ },
138
+ "./name": {
139
+ "require": "./dist/name/index.cjs",
140
+ "import": "./dist/name/index.js",
141
+ "types": "./dist/name/index.d.ts"
142
+ },
143
+ "./name/lineToSmallHump": {
144
+ "require": "./dist/name/lineToSmallHump.cjs",
145
+ "import": "./dist/name/lineToSmallHump.js",
146
+ "types": "./dist/name/lineToSmallHump.d.ts"
105
147
  }
106
- }
148
+ },
149
+ "main": "./dist/index.cjs",
150
+ "module": "./dist/index.js",
151
+ "types": "./dist/index.d.ts"
107
152
  }
@@ -1,11 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunkBEQYORIIcjs = require('../../chunk-BEQYORII.cjs');
6
- require('../../chunk-5AZGAKWR.cjs');
7
-
8
-
9
-
10
-
11
- exports.firstLower = _chunkBEQYORIIcjs.firstLower; exports.firstUpper = _chunkBEQYORIIcjs.firstUpper; exports.getNmaeBar = _chunkBEQYORIIcjs.getNmaeBar;
@@ -1,20 +0,0 @@
1
- /**
2
- * 首字母大写
3
- * @param {string} vs
4
- * @returns string
5
- */
6
- declare function firstUpper(vs: string): string;
7
- /**
8
- * 首字母小写
9
- * @param {string} vs
10
- * @returns string
11
- */
12
- declare function firstLower(vs: string): string;
13
- /**
14
- * 获取-方式组件名称 el-input
15
- * @param {*} name
16
- * @returns
17
- */
18
- declare function getNmaeBar(name: string): string;
19
-
20
- export { firstLower, firstUpper, getNmaeBar };
@@ -1,11 +0,0 @@
1
- import {
2
- firstLower,
3
- firstUpper,
4
- getNmaeBar
5
- } from "../../chunk-DEENZC5X.js";
6
- import "../../chunk-UICA3PK6.js";
7
- export {
8
- firstLower,
9
- firstUpper,
10
- getNmaeBar
11
- };
@@ -1,24 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkYZULJRHHcjs = require('./chunk-YZULJRHH.cjs');
4
-
5
-
6
- var _chunk4PBAZ73Icjs = require('./chunk-4PBAZ73I.cjs');
7
-
8
-
9
- var _chunkJNC5JEFBcjs = require('./chunk-JNC5JEFB.cjs');
10
-
11
-
12
- var _chunk5AZGAKWRcjs = require('./chunk-5AZGAKWR.cjs');
13
-
14
- // packages/basic/index.ts
15
- var basic_exports = {};
16
- _chunk5AZGAKWRcjs.__export.call(void 0, basic_exports, {
17
- array: () => _chunkJNC5JEFBcjs.array_exports,
18
- object: () => _chunkYZULJRHHcjs.object_exports,
19
- string: () => _chunk4PBAZ73Icjs.string_exports
20
- });
21
-
22
-
23
-
24
- exports.basic_exports = basic_exports;
@@ -1,129 +0,0 @@
1
- // packages/basic/object/mergeObject.ts
2
- function mergeObject2(a, b, j = 1, i) {
3
- for (const key in b) {
4
- const v = a[key];
5
- const t = b[key];
6
- if (v) {
7
- if (v instanceof Array) {
8
- if (i) {
9
- if (t instanceof Array) {
10
- v.push(...t);
11
- } else {
12
- v.push(t);
13
- }
14
- } else {
15
- a[key] = t;
16
- }
17
- } else if (typeof v == "object") {
18
- const cv = Object.prototype.toString.call(v);
19
- const ct = Object.prototype.toString.call(t);
20
- if (cv == ct) {
21
- const n = j - 1;
22
- if (n > 0) {
23
- a[key] = mergeObject2(v, t, n, i);
24
- } else {
25
- a[key] = t;
26
- }
27
- } else {
28
- a[key] = t;
29
- }
30
- } else {
31
- a[key] = t;
32
- }
33
- } else {
34
- a[key] = t;
35
- }
36
- }
37
- return a;
38
- }
39
- function unmergeObject(a, b, j = 0, i) {
40
- let c;
41
- if (a instanceof Array) {
42
- if (j > 0 && i) {
43
- c = Object.assign([], a);
44
- if (b instanceof Array) {
45
- for (const v of b) {
46
- if (!a.includes(v)) {
47
- c.push(v);
48
- }
49
- }
50
- } else {
51
- if (!a.includes(b)) {
52
- c.push(b);
53
- }
54
- }
55
- } else {
56
- c = b;
57
- }
58
- } else if (typeof a == "object") {
59
- const cv = Object.prototype.toString.call(a);
60
- const ct = Object.prototype.toString.call(b);
61
- if (a && typeof b == "object" && cv == ct && j > 0) {
62
- c = { ...a };
63
- const n = j - 1;
64
- if (n > 0) {
65
- for (const key in b) {
66
- const v = a[key];
67
- const t = b[key];
68
- c[key] = mergeObject(v, t, n, i);
69
- }
70
- } else {
71
- for (const key in b) {
72
- c[key] = b[key];
73
- }
74
- }
75
- } else {
76
- c = b;
77
- }
78
- } else {
79
- c = b;
80
- }
81
- return c;
82
- }
83
- function mergeObject(a, b, j = 0, i) {
84
- if (a instanceof Array) {
85
- if (j > 0 && i) {
86
- if (b instanceof Array) {
87
- for (const v of b) {
88
- if (!a.includes(v)) {
89
- a.push(v);
90
- }
91
- }
92
- } else {
93
- if (!a.includes(b)) {
94
- a.push(b);
95
- }
96
- }
97
- } else {
98
- a = b;
99
- }
100
- } else if (typeof a == "object") {
101
- const cv = Object.prototype.toString.call(a);
102
- const ct = Object.prototype.toString.call(b);
103
- if (a && typeof b == "object" && cv == ct && j > 0) {
104
- const n = j - 1;
105
- if (n > 0) {
106
- for (const key in b) {
107
- const v = a[key];
108
- const t = b[key];
109
- a[key] = mergeObject(v, t, n, i);
110
- }
111
- } else {
112
- for (const key in b) {
113
- a[key] = b[key];
114
- }
115
- }
116
- } else {
117
- a = b;
118
- }
119
- } else {
120
- a = b;
121
- }
122
- return a;
123
- }
124
-
125
- export {
126
- mergeObject2,
127
- unmergeObject,
128
- mergeObject
129
- };
@@ -1,129 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// packages/basic/object/mergeObject.ts
2
- function mergeObject2(a, b, j = 1, i) {
3
- for (const key in b) {
4
- const v = a[key];
5
- const t = b[key];
6
- if (v) {
7
- if (v instanceof Array) {
8
- if (i) {
9
- if (t instanceof Array) {
10
- v.push(...t);
11
- } else {
12
- v.push(t);
13
- }
14
- } else {
15
- a[key] = t;
16
- }
17
- } else if (typeof v == "object") {
18
- const cv = Object.prototype.toString.call(v);
19
- const ct = Object.prototype.toString.call(t);
20
- if (cv == ct) {
21
- const n = j - 1;
22
- if (n > 0) {
23
- a[key] = mergeObject2(v, t, n, i);
24
- } else {
25
- a[key] = t;
26
- }
27
- } else {
28
- a[key] = t;
29
- }
30
- } else {
31
- a[key] = t;
32
- }
33
- } else {
34
- a[key] = t;
35
- }
36
- }
37
- return a;
38
- }
39
- function unmergeObject(a, b, j = 0, i) {
40
- let c;
41
- if (a instanceof Array) {
42
- if (j > 0 && i) {
43
- c = Object.assign([], a);
44
- if (b instanceof Array) {
45
- for (const v of b) {
46
- if (!a.includes(v)) {
47
- c.push(v);
48
- }
49
- }
50
- } else {
51
- if (!a.includes(b)) {
52
- c.push(b);
53
- }
54
- }
55
- } else {
56
- c = b;
57
- }
58
- } else if (typeof a == "object") {
59
- const cv = Object.prototype.toString.call(a);
60
- const ct = Object.prototype.toString.call(b);
61
- if (a && typeof b == "object" && cv == ct && j > 0) {
62
- c = { ...a };
63
- const n = j - 1;
64
- if (n > 0) {
65
- for (const key in b) {
66
- const v = a[key];
67
- const t = b[key];
68
- c[key] = mergeObject(v, t, n, i);
69
- }
70
- } else {
71
- for (const key in b) {
72
- c[key] = b[key];
73
- }
74
- }
75
- } else {
76
- c = b;
77
- }
78
- } else {
79
- c = b;
80
- }
81
- return c;
82
- }
83
- function mergeObject(a, b, j = 0, i) {
84
- if (a instanceof Array) {
85
- if (j > 0 && i) {
86
- if (b instanceof Array) {
87
- for (const v of b) {
88
- if (!a.includes(v)) {
89
- a.push(v);
90
- }
91
- }
92
- } else {
93
- if (!a.includes(b)) {
94
- a.push(b);
95
- }
96
- }
97
- } else {
98
- a = b;
99
- }
100
- } else if (typeof a == "object") {
101
- const cv = Object.prototype.toString.call(a);
102
- const ct = Object.prototype.toString.call(b);
103
- if (a && typeof b == "object" && cv == ct && j > 0) {
104
- const n = j - 1;
105
- if (n > 0) {
106
- for (const key in b) {
107
- const v = a[key];
108
- const t = b[key];
109
- a[key] = mergeObject(v, t, n, i);
110
- }
111
- } else {
112
- for (const key in b) {
113
- a[key] = b[key];
114
- }
115
- }
116
- } else {
117
- a = b;
118
- }
119
- } else {
120
- a = b;
121
- }
122
- return a;
123
- }
124
-
125
-
126
-
127
-
128
-
129
- exports.mergeObject2 = mergeObject2; exports.unmergeObject = unmergeObject; exports.mergeObject = mergeObject;