law-common 1.2.18 → 1.2.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.
|
@@ -80,3 +80,8 @@ export declare function arrayIntersectionWith<T>(source: T[], target: T[], compa
|
|
|
80
80
|
* console.log(result); // Output: [1, 2, 3, 4]
|
|
81
81
|
*/
|
|
82
82
|
export declare function arrayUnion<T>(source: T[], target: T[]): T[];
|
|
83
|
+
export declare function newRemoved<T>(existing: T[], incoming: T[]): {
|
|
84
|
+
added: T[];
|
|
85
|
+
deleted: T[];
|
|
86
|
+
present: T[];
|
|
87
|
+
};
|
|
@@ -9,6 +9,7 @@ exports.arrayDifference = arrayDifference;
|
|
|
9
9
|
exports.arrayIntersection = arrayIntersection;
|
|
10
10
|
exports.arrayIntersectionWith = arrayIntersectionWith;
|
|
11
11
|
exports.arrayUnion = arrayUnion;
|
|
12
|
+
exports.newRemoved = newRemoved;
|
|
12
13
|
function groupByFunction(list, keyGetter) {
|
|
13
14
|
const map = new Map();
|
|
14
15
|
list.forEach((item) => {
|
|
@@ -128,3 +129,11 @@ function arrayIntersectionWith(source, target, comparator) {
|
|
|
128
129
|
function arrayUnion(source, target) {
|
|
129
130
|
return [...new Set([...source, ...target])];
|
|
130
131
|
}
|
|
132
|
+
function newRemoved(existing, incoming) {
|
|
133
|
+
existing = existing || [];
|
|
134
|
+
incoming = incoming || [];
|
|
135
|
+
const added = arrayDifference(existing, incoming);
|
|
136
|
+
const deleted = arrayDifference(incoming, existing);
|
|
137
|
+
const present = arrayUnion(arrayIntersection(existing, incoming), added);
|
|
138
|
+
return { added, deleted, present };
|
|
139
|
+
}
|