@arrai-innovations/reactive-helpers 2.5.1 → 2.5.2
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/package.json +1 -1
- package/utils/keyDiff.js +12 -5
package/package.json
CHANGED
package/utils/keyDiff.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { difference, intersection } from "./set.js";
|
|
2
2
|
|
|
3
|
-
export function keyDiff(newKeys, oldKeys) {
|
|
3
|
+
export function keyDiff(newKeys, oldKeys, { sameKeys = true, removedKeys = true, addedKeys = true } = {}) {
|
|
4
4
|
const newKeysSet = new Set(newKeys);
|
|
5
5
|
const oldKeysSet = new Set(oldKeys);
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const returnValue = {};
|
|
7
|
+
if (sameKeys) {
|
|
8
|
+
returnValue.sameKeys = intersection(newKeysSet, oldKeysSet);
|
|
9
|
+
}
|
|
10
|
+
if (removedKeys) {
|
|
11
|
+
returnValue.removedKeys = difference(oldKeysSet, newKeysSet);
|
|
12
|
+
}
|
|
13
|
+
if (addedKeys) {
|
|
14
|
+
returnValue.addedKeys = difference(newKeysSet, oldKeysSet);
|
|
15
|
+
}
|
|
16
|
+
return returnValue;
|
|
10
17
|
}
|