@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/keyDiff.js +12 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrai-innovations/reactive-helpers",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "VueJS 3 utility composition functions to help manipulate objects and lists.",
5
5
  "main": "index.js",
6
6
  "directories": {
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 sameKeys = intersection(newKeysSet, oldKeysSet);
7
- const removedKeys = difference(oldKeysSet, newKeysSet);
8
- const addedKeys = difference(newKeysSet, oldKeysSet);
9
- return { sameKeys, removedKeys, addedKeys };
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
  }