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
package/src/libs/confidence.js
CHANGED
|
@@ -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]
|
|
44
|
+
if (sortedArr2.includes(sortedArr1[i])) {
|
|
45
|
+
console.log("Match found:", sortedArr1[i]);
|
|
44
46
|
matches++;
|
|
45
47
|
}
|
|
46
48
|
}
|
package/src/libs/confidence.ts
CHANGED
|
@@ -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
|
});
|