@arrai-innovations/reactive-helpers 8.3.3 → 8.4.0
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 +9 -1
- package/package.json +1 -1
- package/tests/unit/utils/set.spec.js +14 -1
- package/utils/set.js +4 -0
package/README.md
CHANGED
|
@@ -447,7 +447,14 @@ We make use of the basic set operations provided as example on mdn:
|
|
|
447
447
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#implementing_basic_set_operations
|
|
448
448
|
|
|
449
449
|
```js
|
|
450
|
-
import {
|
|
450
|
+
import {
|
|
451
|
+
isSuperset,
|
|
452
|
+
union,
|
|
453
|
+
intersection,
|
|
454
|
+
symmetricDifference,
|
|
455
|
+
difference,
|
|
456
|
+
equals,
|
|
457
|
+
} from "@arrai-innovations/reactive-helpers";
|
|
451
458
|
|
|
452
459
|
isSuperset(new Set([1, 2, 3, 4]), new Set([1, 2, 3])); // true
|
|
453
460
|
union(new Set([1, 2, 3, 4]), new Set([1, 2, 3])); // Set { 1, 2, 3, 4 }
|
|
@@ -455,6 +462,7 @@ intersection(new Set([1, 2, 3, 4]), new Set([1, 2, 3])); // Set { 1, 2, 3 }
|
|
|
455
462
|
symmetricDifference(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5])); // Set { 4, 5 }
|
|
456
463
|
difference(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5])); // Set { 4 }
|
|
457
464
|
difference(new Set([1, 2, 3, 5]), new Set([1, 2, 3, 4])); // Set { 5 }
|
|
465
|
+
equals(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5])); // false
|
|
458
466
|
```
|
|
459
467
|
|
|
460
468
|
#### watches
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { difference, intersection, isSuperset, symmetricDifference, union } from "../../../utils/set.js";
|
|
1
|
+
import { difference, intersection, isSuperset, symmetricDifference, union, equals } from "../../../utils/set.js";
|
|
2
2
|
|
|
3
3
|
describe("utils/set", function () {
|
|
4
4
|
describe("isSuperset", function () {
|
|
@@ -57,6 +57,18 @@ describe("utils/set", function () {
|
|
|
57
57
|
expect(difference(set2, set1)).toEqual(new Set([5, 6]));
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
|
+
describe("equals", function () {
|
|
61
|
+
it("should return true if the two sets are equal", function () {
|
|
62
|
+
const set1 = new Set([1, 2, 3, 4]);
|
|
63
|
+
const set2 = new Set([1, 2, 3, 4]);
|
|
64
|
+
expect(equals(set1, set2)).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
it("should return false if the two sets are not equal", function () {
|
|
67
|
+
const set1 = new Set([1, 2, 3, 4]);
|
|
68
|
+
const set2 = new Set([1, 2, 3, 5]);
|
|
69
|
+
expect(equals(set1, set2)).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
60
72
|
it("should work as in the example for the readme", function () {
|
|
61
73
|
expect(isSuperset(new Set([1, 2, 3, 4]), new Set([1, 2, 3]))).toBe(true);
|
|
62
74
|
expect(union(new Set([1, 2, 3, 4]), new Set([1, 2, 3]))).toEqual(new Set([1, 2, 3, 4]));
|
|
@@ -64,5 +76,6 @@ describe("utils/set", function () {
|
|
|
64
76
|
expect(symmetricDifference(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5]))).toEqual(new Set([4, 5]));
|
|
65
77
|
expect(difference(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5]))).toEqual(new Set([4]));
|
|
66
78
|
expect(difference(new Set([1, 2, 3, 5]), new Set([1, 2, 3, 4]))).toEqual(new Set([5]));
|
|
79
|
+
expect(equals(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 5]))).toBe(false);
|
|
67
80
|
});
|
|
68
81
|
});
|