@contrail/util 1.0.47 → 1.0.48
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 +1 -1
- package/lib/app-util/app-util.d.ts +25 -25
- package/lib/app-util/app-util.js +72 -73
- package/lib/date-util/date-util.d.ts +4 -4
- package/lib/date-util/date-util.js +8 -8
- package/lib/date-util/getIsoDatePart/getIsoDatePart.d.ts +1 -1
- package/lib/date-util/getIsoDatePart/getIsoDatePart.js +17 -17
- package/lib/index.d.ts +5 -5
- package/lib/index.js +21 -21
- package/lib/map-util/map-util.d.ts +3 -3
- package/lib/map-util/map-util.js +18 -18
- package/lib/object-util/applyChangesIfEqual/applyChangesIfEqual.d.ts +4 -4
- package/lib/object-util/applyChangesIfEqual/applyChangesIfEqual.js +84 -84
- package/lib/object-util/cloneDeep/cloneDeep.d.ts +1 -1
- package/lib/object-util/cloneDeep/cloneDeep.js +10 -10
- package/lib/object-util/compareDeep/compareDeep.d.ts +7 -7
- package/lib/object-util/compareDeep/compareDeep.js +96 -90
- package/lib/object-util/compareDeep/mockData.d.ts +88 -88
- package/lib/object-util/compareDeep/mockData.js +91 -91
- package/lib/object-util/isObject/isObject.d.ts +1 -1
- package/lib/object-util/isObject/isObject.js +7 -7
- package/lib/object-util/mergeDeep/mergeDeep.d.ts +1 -1
- package/lib/object-util/mergeDeep/mergeDeep.js +26 -26
- package/lib/object-util/object-util.d.ts +17 -17
- package/lib/object-util/object-util.js +41 -44
- package/lib/string-util/string-util.d.ts +8 -8
- package/lib/string-util/string-util.js +71 -69
- package/package.json +43 -42
|
@@ -1,90 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getObjectDiff = exports.getObjectDiffs = void 0;
|
|
4
|
-
function getObjectDiffs(before, after, prefix) {
|
|
5
|
-
const diffs = [];
|
|
6
|
-
if (!before || !after) {
|
|
7
|
-
return diffs;
|
|
8
|
-
}
|
|
9
|
-
const beforeProperties = Object.getOwnPropertyNames(before);
|
|
10
|
-
const afterProperties = Object.getOwnPropertyNames(after);
|
|
11
|
-
const addedProperties = afterProperties.filter(value => !beforeProperties.includes(value));
|
|
12
|
-
const deletedProperties = beforeProperties.filter(value => !afterProperties.includes(value));
|
|
13
|
-
const commonProperties = beforeProperties.filter(value => afterProperties.includes(value));
|
|
14
|
-
addedProperties.forEach(addedProperty => {
|
|
15
|
-
diffs.push(getObjectDiff(null, after[addedProperty], prefix + addedProperty));
|
|
16
|
-
});
|
|
17
|
-
deletedProperties.forEach(deletedProperty => {
|
|
18
|
-
diffs.push(getObjectDiff(before[deletedProperty], null, prefix + deletedProperty));
|
|
19
|
-
});
|
|
20
|
-
commonProperties.forEach(commonProperty => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getObjectDiff = exports.getObjectDiffs = void 0;
|
|
4
|
+
function getObjectDiffs(before, after, prefix) {
|
|
5
|
+
const diffs = [];
|
|
6
|
+
if (!before || !after) {
|
|
7
|
+
return diffs;
|
|
8
|
+
}
|
|
9
|
+
const beforeProperties = Object.getOwnPropertyNames(before);
|
|
10
|
+
const afterProperties = Object.getOwnPropertyNames(after);
|
|
11
|
+
const addedProperties = afterProperties.filter((value) => !beforeProperties.includes(value));
|
|
12
|
+
const deletedProperties = beforeProperties.filter((value) => !afterProperties.includes(value));
|
|
13
|
+
const commonProperties = beforeProperties.filter((value) => afterProperties.includes(value));
|
|
14
|
+
addedProperties.forEach((addedProperty) => {
|
|
15
|
+
diffs.push(getObjectDiff(null, after[addedProperty], prefix + addedProperty));
|
|
16
|
+
});
|
|
17
|
+
deletedProperties.forEach((deletedProperty) => {
|
|
18
|
+
diffs.push(getObjectDiff(before[deletedProperty], null, prefix + deletedProperty));
|
|
19
|
+
});
|
|
20
|
+
commonProperties.forEach((commonProperty) => {
|
|
21
|
+
let beforeVal = before[commonProperty];
|
|
22
|
+
if (beforeVal === undefined || beforeVal === '') {
|
|
23
|
+
beforeVal = null;
|
|
24
|
+
}
|
|
25
|
+
let afterVal = after[commonProperty];
|
|
26
|
+
if (afterVal === undefined || afterVal === '') {
|
|
27
|
+
afterVal = null;
|
|
28
|
+
}
|
|
29
|
+
if (beforeVal === afterVal) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (beforeVal === null || afterVal === null) {
|
|
33
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (typeof beforeVal !== typeof afterVal) {
|
|
37
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (isObject(beforeVal)) {
|
|
41
|
+
if (isDate(beforeVal)) {
|
|
42
|
+
if (!datesEqual(beforeVal, afterVal)) {
|
|
43
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (Array.isArray(beforeVal) && Array.isArray(afterVal)) {
|
|
47
|
+
const beforeArray = [...beforeVal].sort(sortFunc);
|
|
48
|
+
const afterArray = [...afterVal].sort(sortFunc);
|
|
49
|
+
if (JSON.stringify(beforeArray) !== JSON.stringify(afterArray)) {
|
|
50
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (Array.isArray(beforeVal) && !Array.isArray(afterVal)) {
|
|
54
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const nestedObjectDiffs = getObjectDiffs(beforeVal, afterVal, prefix + commonProperty + '.');
|
|
58
|
+
diffs.push(...nestedObjectDiffs);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (beforeVal !== afterVal) {
|
|
63
|
+
diffs.push(getObjectDiff(beforeVal, afterVal, prefix + commonProperty));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return diffs;
|
|
68
|
+
}
|
|
69
|
+
exports.getObjectDiffs = getObjectDiffs;
|
|
70
|
+
function getObjectDiff(before, after, name) {
|
|
71
|
+
const diff = {
|
|
72
|
+
propertyName: name,
|
|
73
|
+
oldValue: before,
|
|
74
|
+
newValue: after,
|
|
75
|
+
};
|
|
76
|
+
return diff;
|
|
77
|
+
}
|
|
78
|
+
exports.getObjectDiff = getObjectDiff;
|
|
79
|
+
function sortFunc(x, y) {
|
|
80
|
+
const pre = ['string', 'number', 'bool'];
|
|
81
|
+
if (typeof x !== typeof y)
|
|
82
|
+
return pre.indexOf(typeof y) - pre.indexOf(typeof x);
|
|
83
|
+
if (x === y)
|
|
84
|
+
return 0;
|
|
85
|
+
else
|
|
86
|
+
return x > y ? 1 : -1;
|
|
87
|
+
}
|
|
88
|
+
function isObject(object) {
|
|
89
|
+
return object != null && typeof object === 'object';
|
|
90
|
+
}
|
|
91
|
+
function isDate(object) {
|
|
92
|
+
return object != null && object instanceof Date;
|
|
93
|
+
}
|
|
94
|
+
function datesEqual(date1, date2) {
|
|
95
|
+
return date1.getTime() === date2.getTime();
|
|
96
|
+
}
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
export declare const item1Assortment1: {
|
|
2
|
-
id: string;
|
|
3
|
-
stringProperty: string;
|
|
4
|
-
intProperty: number;
|
|
5
|
-
boolProperty: boolean;
|
|
6
|
-
dateProperty: Date;
|
|
7
|
-
arrayProperty: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare const item1Assortment2: {
|
|
10
|
-
id: string;
|
|
11
|
-
stringProperty: string;
|
|
12
|
-
intProperty: number;
|
|
13
|
-
boolProperty: boolean;
|
|
14
|
-
dateProperty: Date;
|
|
15
|
-
arrayProperty: string[];
|
|
16
|
-
};
|
|
17
|
-
export declare const item1Assortment3: {
|
|
18
|
-
id: string;
|
|
19
|
-
stringProperty: string;
|
|
20
|
-
intProperty: number;
|
|
21
|
-
boolProperty: boolean;
|
|
22
|
-
dateProperty: Date;
|
|
23
|
-
arrayProperty: any;
|
|
24
|
-
};
|
|
25
|
-
export declare const item2Assortment1: {
|
|
26
|
-
id: string;
|
|
27
|
-
stringProperty: string;
|
|
28
|
-
intProperty: number;
|
|
29
|
-
boolProperty: boolean;
|
|
30
|
-
dateProperty: Date;
|
|
31
|
-
arrayProperty: string[];
|
|
32
|
-
};
|
|
33
|
-
export declare const item2Assortment2ScalarChange: {
|
|
34
|
-
id: string;
|
|
35
|
-
stringProperty: string;
|
|
36
|
-
intProperty: number;
|
|
37
|
-
boolProperty: boolean;
|
|
38
|
-
dateProperty: Date;
|
|
39
|
-
arrayProperty: string[];
|
|
40
|
-
};
|
|
41
|
-
export declare const item2Assortment2ArrayChange: {
|
|
42
|
-
id: string;
|
|
43
|
-
stringProperty: string;
|
|
44
|
-
intProperty: number;
|
|
45
|
-
boolProperty: boolean;
|
|
46
|
-
dateProperty: Date;
|
|
47
|
-
arrayProperty: string[];
|
|
48
|
-
};
|
|
49
|
-
export declare const item2Assortment2DateChange: {
|
|
50
|
-
id: string;
|
|
51
|
-
stringProperty: string;
|
|
52
|
-
intProperty: number;
|
|
53
|
-
boolProperty: boolean;
|
|
54
|
-
dateProperty: Date;
|
|
55
|
-
arrayProperty: string[];
|
|
56
|
-
};
|
|
57
|
-
export declare const item3Assortment1: {
|
|
58
|
-
id: string;
|
|
59
|
-
stringProperty: string;
|
|
60
|
-
intProperty: number;
|
|
61
|
-
boolProperty: boolean;
|
|
62
|
-
dateProperty: Date;
|
|
63
|
-
arrayProperty: string[];
|
|
64
|
-
nestedProperties: {
|
|
65
|
-
nestedBoolProperty: boolean;
|
|
66
|
-
nestedDateProperty: Date;
|
|
67
|
-
nestedArrayProperty: string[];
|
|
68
|
-
nestedObject: {
|
|
69
|
-
nestedBoolProperty: boolean;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export declare const item3Assortment2NestedChanges: {
|
|
74
|
-
id: string;
|
|
75
|
-
stringProperty: string;
|
|
76
|
-
intProperty: number;
|
|
77
|
-
boolProperty: boolean;
|
|
78
|
-
dateProperty: Date;
|
|
79
|
-
arrayProperty: string[];
|
|
80
|
-
nestedProperties: {
|
|
81
|
-
nestedBoolProperty: boolean;
|
|
82
|
-
nestedDateProperty: Date;
|
|
83
|
-
nestedArrayProperty: string[];
|
|
84
|
-
nestedObject: {
|
|
85
|
-
nestedBoolProperty: boolean;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
};
|
|
1
|
+
export declare const item1Assortment1: {
|
|
2
|
+
id: string;
|
|
3
|
+
stringProperty: string;
|
|
4
|
+
intProperty: number;
|
|
5
|
+
boolProperty: boolean;
|
|
6
|
+
dateProperty: Date;
|
|
7
|
+
arrayProperty: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare const item1Assortment2: {
|
|
10
|
+
id: string;
|
|
11
|
+
stringProperty: string;
|
|
12
|
+
intProperty: number;
|
|
13
|
+
boolProperty: boolean;
|
|
14
|
+
dateProperty: Date;
|
|
15
|
+
arrayProperty: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare const item1Assortment3: {
|
|
18
|
+
id: string;
|
|
19
|
+
stringProperty: string;
|
|
20
|
+
intProperty: number;
|
|
21
|
+
boolProperty: boolean;
|
|
22
|
+
dateProperty: Date;
|
|
23
|
+
arrayProperty: any;
|
|
24
|
+
};
|
|
25
|
+
export declare const item2Assortment1: {
|
|
26
|
+
id: string;
|
|
27
|
+
stringProperty: string;
|
|
28
|
+
intProperty: number;
|
|
29
|
+
boolProperty: boolean;
|
|
30
|
+
dateProperty: Date;
|
|
31
|
+
arrayProperty: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare const item2Assortment2ScalarChange: {
|
|
34
|
+
id: string;
|
|
35
|
+
stringProperty: string;
|
|
36
|
+
intProperty: number;
|
|
37
|
+
boolProperty: boolean;
|
|
38
|
+
dateProperty: Date;
|
|
39
|
+
arrayProperty: string[];
|
|
40
|
+
};
|
|
41
|
+
export declare const item2Assortment2ArrayChange: {
|
|
42
|
+
id: string;
|
|
43
|
+
stringProperty: string;
|
|
44
|
+
intProperty: number;
|
|
45
|
+
boolProperty: boolean;
|
|
46
|
+
dateProperty: Date;
|
|
47
|
+
arrayProperty: string[];
|
|
48
|
+
};
|
|
49
|
+
export declare const item2Assortment2DateChange: {
|
|
50
|
+
id: string;
|
|
51
|
+
stringProperty: string;
|
|
52
|
+
intProperty: number;
|
|
53
|
+
boolProperty: boolean;
|
|
54
|
+
dateProperty: Date;
|
|
55
|
+
arrayProperty: string[];
|
|
56
|
+
};
|
|
57
|
+
export declare const item3Assortment1: {
|
|
58
|
+
id: string;
|
|
59
|
+
stringProperty: string;
|
|
60
|
+
intProperty: number;
|
|
61
|
+
boolProperty: boolean;
|
|
62
|
+
dateProperty: Date;
|
|
63
|
+
arrayProperty: string[];
|
|
64
|
+
nestedProperties: {
|
|
65
|
+
nestedBoolProperty: boolean;
|
|
66
|
+
nestedDateProperty: Date;
|
|
67
|
+
nestedArrayProperty: string[];
|
|
68
|
+
nestedObject: {
|
|
69
|
+
nestedBoolProperty: boolean;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare const item3Assortment2NestedChanges: {
|
|
74
|
+
id: string;
|
|
75
|
+
stringProperty: string;
|
|
76
|
+
intProperty: number;
|
|
77
|
+
boolProperty: boolean;
|
|
78
|
+
dateProperty: Date;
|
|
79
|
+
arrayProperty: string[];
|
|
80
|
+
nestedProperties: {
|
|
81
|
+
nestedBoolProperty: boolean;
|
|
82
|
+
nestedDateProperty: Date;
|
|
83
|
+
nestedArrayProperty: string[];
|
|
84
|
+
nestedObject: {
|
|
85
|
+
nestedBoolProperty: boolean;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.item3Assortment2NestedChanges = exports.item3Assortment1 = exports.item2Assortment2DateChange = exports.item2Assortment2ArrayChange = exports.item2Assortment2ScalarChange = exports.item2Assortment1 = exports.item1Assortment3 = exports.item1Assortment2 = exports.item1Assortment1 = void 0;
|
|
4
|
-
exports.item1Assortment1 = {
|
|
5
|
-
id: 'id1',
|
|
6
|
-
stringProperty: 'stringProperty1',
|
|
7
|
-
intProperty: 1,
|
|
8
|
-
boolProperty: false,
|
|
9
|
-
dateProperty: new Date('12/22/1994'),
|
|
10
|
-
arrayProperty: ['A', 'B', 'C'],
|
|
11
|
-
};
|
|
12
|
-
exports.item1Assortment2 = {
|
|
13
|
-
id: 'id1',
|
|
14
|
-
stringProperty: 'stringProperty1',
|
|
15
|
-
intProperty: 1,
|
|
16
|
-
boolProperty: false,
|
|
17
|
-
dateProperty: new Date('12/22/1994'),
|
|
18
|
-
arrayProperty: ['A', 'B', 'C'],
|
|
19
|
-
};
|
|
20
|
-
exports.item1Assortment3 = {
|
|
21
|
-
id: 'id1',
|
|
22
|
-
stringProperty: 'stringProperty1',
|
|
23
|
-
intProperty: 1,
|
|
24
|
-
boolProperty: false,
|
|
25
|
-
dateProperty: new Date('12/22/1994'),
|
|
26
|
-
arrayProperty: null,
|
|
27
|
-
};
|
|
28
|
-
exports.item2Assortment1 = {
|
|
29
|
-
id: 'id2',
|
|
30
|
-
stringProperty: 'stringProperty2',
|
|
31
|
-
intProperty: 2,
|
|
32
|
-
boolProperty: false,
|
|
33
|
-
dateProperty: new Date('12/23/1994'),
|
|
34
|
-
arrayProperty: ['A', 'B'],
|
|
35
|
-
};
|
|
36
|
-
exports.item2Assortment2ScalarChange = {
|
|
37
|
-
id: 'id2',
|
|
38
|
-
stringProperty: 'stringProperty3Update',
|
|
39
|
-
intProperty: 4,
|
|
40
|
-
boolProperty: true,
|
|
41
|
-
dateProperty: new Date('12/23/1994'),
|
|
42
|
-
arrayProperty: ['A', 'B'],
|
|
43
|
-
};
|
|
44
|
-
exports.item2Assortment2ArrayChange = {
|
|
45
|
-
id: 'id2',
|
|
46
|
-
stringProperty: 'stringProperty2',
|
|
47
|
-
intProperty: 2,
|
|
48
|
-
boolProperty: false,
|
|
49
|
-
dateProperty: new Date('12/23/1994'),
|
|
50
|
-
arrayProperty: ['A', 'B', 'D'],
|
|
51
|
-
};
|
|
52
|
-
exports.item2Assortment2DateChange = {
|
|
53
|
-
id: 'id2',
|
|
54
|
-
stringProperty: 'stringProperty2',
|
|
55
|
-
intProperty: 2,
|
|
56
|
-
boolProperty: false,
|
|
57
|
-
dateProperty: new Date('12/23/1995'),
|
|
58
|
-
arrayProperty: ['A', 'B'],
|
|
59
|
-
};
|
|
60
|
-
exports.item3Assortment1 = {
|
|
61
|
-
id: 'id3',
|
|
62
|
-
stringProperty: 'stringProperty2',
|
|
63
|
-
intProperty: 2,
|
|
64
|
-
boolProperty: false,
|
|
65
|
-
dateProperty: new Date('12/23/1994'),
|
|
66
|
-
arrayProperty: ['A', 'B'],
|
|
67
|
-
nestedProperties: {
|
|
68
|
-
nestedBoolProperty: false,
|
|
69
|
-
nestedDateProperty: new Date('12/22/1994'),
|
|
70
|
-
nestedArrayProperty: ['C', 'D'],
|
|
71
|
-
nestedObject: {
|
|
72
|
-
nestedBoolProperty: false,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
exports.item3Assortment2NestedChanges = {
|
|
77
|
-
id: 'id3',
|
|
78
|
-
stringProperty: 'stringProperty2',
|
|
79
|
-
intProperty: 2,
|
|
80
|
-
boolProperty: true,
|
|
81
|
-
dateProperty: new Date('12/23/1994'),
|
|
82
|
-
arrayProperty: ['A', 'B'],
|
|
83
|
-
nestedProperties: {
|
|
84
|
-
nestedBoolProperty: false,
|
|
85
|
-
nestedDateProperty: new Date('12/23/1995'),
|
|
86
|
-
nestedArrayProperty: ['C', 'D', 'A'],
|
|
87
|
-
nestedObject: {
|
|
88
|
-
nestedBoolProperty: true,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.item3Assortment2NestedChanges = exports.item3Assortment1 = exports.item2Assortment2DateChange = exports.item2Assortment2ArrayChange = exports.item2Assortment2ScalarChange = exports.item2Assortment1 = exports.item1Assortment3 = exports.item1Assortment2 = exports.item1Assortment1 = void 0;
|
|
4
|
+
exports.item1Assortment1 = {
|
|
5
|
+
id: 'id1',
|
|
6
|
+
stringProperty: 'stringProperty1',
|
|
7
|
+
intProperty: 1,
|
|
8
|
+
boolProperty: false,
|
|
9
|
+
dateProperty: new Date('12/22/1994'),
|
|
10
|
+
arrayProperty: ['A', 'B', 'C'],
|
|
11
|
+
};
|
|
12
|
+
exports.item1Assortment2 = {
|
|
13
|
+
id: 'id1',
|
|
14
|
+
stringProperty: 'stringProperty1',
|
|
15
|
+
intProperty: 1,
|
|
16
|
+
boolProperty: false,
|
|
17
|
+
dateProperty: new Date('12/22/1994'),
|
|
18
|
+
arrayProperty: ['A', 'B', 'C'],
|
|
19
|
+
};
|
|
20
|
+
exports.item1Assortment3 = {
|
|
21
|
+
id: 'id1',
|
|
22
|
+
stringProperty: 'stringProperty1',
|
|
23
|
+
intProperty: 1,
|
|
24
|
+
boolProperty: false,
|
|
25
|
+
dateProperty: new Date('12/22/1994'),
|
|
26
|
+
arrayProperty: null,
|
|
27
|
+
};
|
|
28
|
+
exports.item2Assortment1 = {
|
|
29
|
+
id: 'id2',
|
|
30
|
+
stringProperty: 'stringProperty2',
|
|
31
|
+
intProperty: 2,
|
|
32
|
+
boolProperty: false,
|
|
33
|
+
dateProperty: new Date('12/23/1994'),
|
|
34
|
+
arrayProperty: ['A', 'B'],
|
|
35
|
+
};
|
|
36
|
+
exports.item2Assortment2ScalarChange = {
|
|
37
|
+
id: 'id2',
|
|
38
|
+
stringProperty: 'stringProperty3Update',
|
|
39
|
+
intProperty: 4,
|
|
40
|
+
boolProperty: true,
|
|
41
|
+
dateProperty: new Date('12/23/1994'),
|
|
42
|
+
arrayProperty: ['A', 'B'],
|
|
43
|
+
};
|
|
44
|
+
exports.item2Assortment2ArrayChange = {
|
|
45
|
+
id: 'id2',
|
|
46
|
+
stringProperty: 'stringProperty2',
|
|
47
|
+
intProperty: 2,
|
|
48
|
+
boolProperty: false,
|
|
49
|
+
dateProperty: new Date('12/23/1994'),
|
|
50
|
+
arrayProperty: ['A', 'B', 'D'],
|
|
51
|
+
};
|
|
52
|
+
exports.item2Assortment2DateChange = {
|
|
53
|
+
id: 'id2',
|
|
54
|
+
stringProperty: 'stringProperty2',
|
|
55
|
+
intProperty: 2,
|
|
56
|
+
boolProperty: false,
|
|
57
|
+
dateProperty: new Date('12/23/1995'),
|
|
58
|
+
arrayProperty: ['A', 'B'],
|
|
59
|
+
};
|
|
60
|
+
exports.item3Assortment1 = {
|
|
61
|
+
id: 'id3',
|
|
62
|
+
stringProperty: 'stringProperty2',
|
|
63
|
+
intProperty: 2,
|
|
64
|
+
boolProperty: false,
|
|
65
|
+
dateProperty: new Date('12/23/1994'),
|
|
66
|
+
arrayProperty: ['A', 'B'],
|
|
67
|
+
nestedProperties: {
|
|
68
|
+
nestedBoolProperty: false,
|
|
69
|
+
nestedDateProperty: new Date('12/22/1994'),
|
|
70
|
+
nestedArrayProperty: ['C', 'D'],
|
|
71
|
+
nestedObject: {
|
|
72
|
+
nestedBoolProperty: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
exports.item3Assortment2NestedChanges = {
|
|
77
|
+
id: 'id3',
|
|
78
|
+
stringProperty: 'stringProperty2',
|
|
79
|
+
intProperty: 2,
|
|
80
|
+
boolProperty: true,
|
|
81
|
+
dateProperty: new Date('12/23/1994'),
|
|
82
|
+
arrayProperty: ['A', 'B'],
|
|
83
|
+
nestedProperties: {
|
|
84
|
+
nestedBoolProperty: false,
|
|
85
|
+
nestedDateProperty: new Date('12/23/1995'),
|
|
86
|
+
nestedArrayProperty: ['C', 'D', 'A'],
|
|
87
|
+
nestedObject: {
|
|
88
|
+
nestedBoolProperty: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isObject(item: any): boolean;
|
|
1
|
+
export declare function isObject(item: any): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObject = void 0;
|
|
4
|
-
function isObject(item) {
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
exports.isObject = isObject;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isObject = void 0;
|
|
4
|
+
function isObject(item) {
|
|
5
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
6
|
+
}
|
|
7
|
+
exports.isObject = isObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function mergeDeep(target: any, ...sources: any[]): any;
|
|
1
|
+
export declare function mergeDeep(target: any, ...sources: any[]): any;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeDeep = void 0;
|
|
4
|
-
const isObject_1 = require("../isObject/isObject");
|
|
5
|
-
function mergeDeep(target, ...sources) {
|
|
6
|
-
if (!sources.length)
|
|
7
|
-
return target;
|
|
8
|
-
const source = sources.shift();
|
|
9
|
-
if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
|
|
10
|
-
for (const key in source) {
|
|
11
|
-
if ((0, isObject_1.isObject)(source[key]) && !isDate(source[key])) {
|
|
12
|
-
if (!target[key])
|
|
13
|
-
Object.assign(target, { [key]: {} });
|
|
14
|
-
mergeDeep(target[key], source[key]);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
Object.assign(target, { [key]: source[key] });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return mergeDeep(target, ...sources);
|
|
22
|
-
}
|
|
23
|
-
exports.mergeDeep = mergeDeep;
|
|
24
|
-
function isDate(object) {
|
|
25
|
-
return object != null && object instanceof Date;
|
|
26
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeDeep = void 0;
|
|
4
|
+
const isObject_1 = require("../isObject/isObject");
|
|
5
|
+
function mergeDeep(target, ...sources) {
|
|
6
|
+
if (!sources.length)
|
|
7
|
+
return target;
|
|
8
|
+
const source = sources.shift();
|
|
9
|
+
if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
|
|
10
|
+
for (const key in source) {
|
|
11
|
+
if ((0, isObject_1.isObject)(source[key]) && !isDate(source[key])) {
|
|
12
|
+
if (!target[key])
|
|
13
|
+
Object.assign(target, { [key]: {} });
|
|
14
|
+
mergeDeep(target[key], source[key]);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
Object.assign(target, { [key]: source[key] });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return mergeDeep(target, ...sources);
|
|
22
|
+
}
|
|
23
|
+
exports.mergeDeep = mergeDeep;
|
|
24
|
+
function isDate(object) {
|
|
25
|
+
return object != null && object instanceof Date;
|
|
26
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { cloneDeep } from './cloneDeep/cloneDeep';
|
|
2
|
-
import { isObject } from './isObject/isObject';
|
|
3
|
-
import { mergeDeep } from './mergeDeep/mergeDeep';
|
|
4
|
-
import { getObjectDiffs } from './compareDeep/compareDeep';
|
|
5
|
-
import { applyChangesIfEqual, determineChangesIfEqual, areItemPropertyValuesEqual } from './applyChangesIfEqual/applyChangesIfEqual';
|
|
6
|
-
export { ObjectDiff } from './compareDeep/compareDeep';
|
|
7
|
-
export declare class ObjectUtil {
|
|
8
|
-
static getByPath(obj: any, path: string, def?: any): any;
|
|
9
|
-
static setByPath(obj: any, path: string, value: any): void;
|
|
10
|
-
static isObject: typeof isObject;
|
|
11
|
-
static mergeDeep: typeof mergeDeep;
|
|
12
|
-
static cloneDeep: typeof cloneDeep;
|
|
13
|
-
static compareDeep: typeof getObjectDiffs;
|
|
14
|
-
static applyChangesIfEqual: typeof applyChangesIfEqual;
|
|
15
|
-
static determineChangesIfEqual: typeof determineChangesIfEqual;
|
|
16
|
-
static areItemPropertyValuesEqual: typeof areItemPropertyValuesEqual;
|
|
17
|
-
}
|
|
1
|
+
import { cloneDeep } from './cloneDeep/cloneDeep';
|
|
2
|
+
import { isObject } from './isObject/isObject';
|
|
3
|
+
import { mergeDeep } from './mergeDeep/mergeDeep';
|
|
4
|
+
import { getObjectDiffs } from './compareDeep/compareDeep';
|
|
5
|
+
import { applyChangesIfEqual, determineChangesIfEqual, areItemPropertyValuesEqual } from './applyChangesIfEqual/applyChangesIfEqual';
|
|
6
|
+
export { ObjectDiff } from './compareDeep/compareDeep';
|
|
7
|
+
export declare class ObjectUtil {
|
|
8
|
+
static getByPath(obj: any, path: string, def?: any): any;
|
|
9
|
+
static setByPath(obj: any, path: string, value: any): void;
|
|
10
|
+
static isObject: typeof isObject;
|
|
11
|
+
static mergeDeep: typeof mergeDeep;
|
|
12
|
+
static cloneDeep: typeof cloneDeep;
|
|
13
|
+
static compareDeep: typeof getObjectDiffs;
|
|
14
|
+
static applyChangesIfEqual: typeof applyChangesIfEqual;
|
|
15
|
+
static determineChangesIfEqual: typeof determineChangesIfEqual;
|
|
16
|
+
static areItemPropertyValuesEqual: typeof areItemPropertyValuesEqual;
|
|
17
|
+
}
|