devicer.js 1.0.12 → 1.0.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devicer.js",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Open-Source Digital Fingerprinting Middleware",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -26,6 +26,7 @@ function compareArrays(arr1, arr2, max_depth = 5) {
26
26
  return undefined;
27
27
  }
28
28
  });
29
+ console.log("Sorted Arrays:", sortedArr1, sortedArr2);
29
30
  const maxLength = Math.min(arr1.length, arr2.length);
30
31
  for (let i = 0; i < maxLength; i++) {
31
32
  fields++;
@@ -40,7 +41,8 @@ function compareArrays(arr1, arr2, max_depth = 5) {
40
41
  fields += subData[0] - 1; // Subtract 1 for the index itself
41
42
  matches += subData[1];
42
43
  }
43
- if (sortedArr1[i] === sortedArr2[i]) {
44
+ if (sortedArr2.includes(sortedArr1[i])) {
45
+ console.log("Match found:", sortedArr1[i]);
44
46
  matches++;
45
47
  }
46
48
  }
@@ -60,7 +60,7 @@ export function compareArrays(
60
60
  matches += subData[1];
61
61
  }
62
62
 
63
- if (sortedArr1[i] === sortedArr2[i]) {
63
+ if (sortedArr2.includes(sortedArr1[i])) {
64
64
  matches++;
65
65
  }
66
66
  }
@@ -79,4 +79,20 @@ describe("Array Comparison", () => {
79
79
  const arr2 = [1, [2, [3, [4, [5, [6]]]]]];
80
80
  expect(() => compareArrays(arr1, arr2, 0)).toThrow("Max depth exceeded");
81
81
  });
82
+
83
+ it("should handle arrays with shuffled identical elements", () => {
84
+ const arr1 = [1, 2, 3];
85
+ const arr2 = [3, 1, 2];
86
+ const result = compareArrays(arr1, arr2);
87
+ console.log("Result:", result);
88
+ expect(result).toEqual([3, 3]); // 3 fields, 3 matches
89
+ });
90
+
91
+ it("should handle arrays with shuffled different elements", () => {
92
+ const arr1 = ["a", "b", "c"];
93
+ const arr2 = ["c", "d", "a"];
94
+ const result = compareArrays(arr1, arr2);
95
+ console.log("Result:", result);
96
+ expect(result).toEqual([3, 2]); // 3 fields, 3 matches
97
+ });
82
98
  });