ismx-nexo-node-app 0.4.119 → 0.4.120
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.
|
@@ -52,6 +52,18 @@ class ArrayUtils {
|
|
|
52
52
|
const onlyInArr2 = ArrayUtils.subtract(arr2, arr1);
|
|
53
53
|
return Array.from(new Set([...onlyInArr1, ...onlyInArr2]).values());
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the intersection of two arrays.
|
|
57
|
+
* It will include only the elements that exist in both arrays.
|
|
58
|
+
*
|
|
59
|
+
* @param {T[]} arr1 - The first array to intersect.
|
|
60
|
+
* @param {T[]} arr2 - The second array to intersect.
|
|
61
|
+
* @return {T[]} An array containing only the elements present in both arr1 and arr2.
|
|
62
|
+
* @template T
|
|
63
|
+
*/
|
|
64
|
+
static intersect(arr1, arr2) {
|
|
65
|
+
return arr1.filter(item => arr2.includes(item));
|
|
66
|
+
}
|
|
55
67
|
/**
|
|
56
68
|
* Toggles the presence of an item in an array. If the item exists in the array, it is removed;
|
|
57
69
|
* if it does not exist, it is added.
|
|
@@ -25,6 +25,16 @@ export default abstract class ArrayUtils {
|
|
|
25
25
|
* @template T
|
|
26
26
|
*/
|
|
27
27
|
static diff<T>(arr1: T[], arr2: T[]): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns the intersection of two arrays.
|
|
30
|
+
* It will include only the elements that exist in both arrays.
|
|
31
|
+
*
|
|
32
|
+
* @param {T[]} arr1 - The first array to intersect.
|
|
33
|
+
* @param {T[]} arr2 - The second array to intersect.
|
|
34
|
+
* @return {T[]} An array containing only the elements present in both arr1 and arr2.
|
|
35
|
+
* @template T
|
|
36
|
+
*/
|
|
37
|
+
static intersect<T>(arr1: T[], arr2: T[]): T[];
|
|
28
38
|
/**
|
|
29
39
|
* Toggles the presence of an item in an array. If the item exists in the array, it is removed;
|
|
30
40
|
* if it does not exist, it is added.
|
package/package.json
CHANGED
|
@@ -41,6 +41,19 @@ export default abstract class ArrayUtils {
|
|
|
41
41
|
return Array.from(new Set([...onlyInArr1, ...onlyInArr2]).values());
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Returns the intersection of two arrays.
|
|
46
|
+
* It will include only the elements that exist in both arrays.
|
|
47
|
+
*
|
|
48
|
+
* @param {T[]} arr1 - The first array to intersect.
|
|
49
|
+
* @param {T[]} arr2 - The second array to intersect.
|
|
50
|
+
* @return {T[]} An array containing only the elements present in both arr1 and arr2.
|
|
51
|
+
* @template T
|
|
52
|
+
*/
|
|
53
|
+
static intersect<T>(arr1: T[], arr2: T[]): T[] {
|
|
54
|
+
return arr1.filter(item => arr2.includes(item));
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
/**
|
|
45
58
|
* Toggles the presence of an item in an array. If the item exists in the array, it is removed;
|
|
46
59
|
* if it does not exist, it is added.
|