devicer.js 1.0.11 → 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 +1 -1
- package/src/libs/confidence.js +3 -1
- package/src/libs/confidence.ts +1 -1
- package/tests/comparisons.test.ts +20 -14
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 (
|
|
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
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { compareArrays, compareDatasets } from "../src/libs/confidence";
|
|
3
3
|
|
|
4
|
-
const sampleData1 = {"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0","platform":"Win32","timezone":"America/Chicago","language":"en-US","languages":["en-US","en","es","la"],"cookieEnabled":true,"doNotTrack":"1","hardwareConcurrency":8,"deviceMemory":8,"product":"Gecko","productSub":"20030107","vendor":"Google Inc.","vendorSub":"unknown","appName":"Netscape","appVersion":"5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0","appCodeName":"Mozilla","appMinorVersion":"unknown","buildID":"unknown","plugins":[{"name":"PDF Viewer","description":"Portable Document Format"},{"name":"Chrome PDF Viewer","description":"Portable Document Format"},{"name":"Chromium PDF Viewer","description":"Portable Document Format"},{"name":"Microsoft Edge PDF Viewer","description":"Portable Document Format"},{"name":"WebKit built-in PDF","description":"Portable Document Format"}],"mimeTypes":[{"type":"application/pdf","suffixes":"pdf","description":"Portable Document Format"},{"type":"text/pdf","suffixes":"pdf","description":"Portable Document Format"}],"screen":{"width":1920,"height":1080,"colorDepth":24,"pixelDepth":24,"orientation":{"type":"landscape-primary","angle":0}},"highEntropyValues":{"architecture":"x86","bitness":"64","brands":[{"brand":"Not)A;Brand","version":"8"},{"brand":"Chromium","version":"138"},{"brand":"Microsoft Edge","version":"138"}],"mobile":false,"model":"","platform":"Windows","platformVersion":"19.0.0","uaFullVersion":"138.0.3351.34"}};
|
|
5
|
-
|
|
6
|
-
const sampleData2 = {"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36","platform":"Win32","timezone":"America/Chicago","language":"en-US","languages":["en-US","en"],"cookieEnabled":true,"hardwareConcurrency":16,"deviceMemory":8,"product":"Gecko","productSub":"20030107","vendor":"Google Inc.","vendorSub":"unknown","appName":"Netscape","appVersion":"5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36","appCodeName":"Mozilla","appMinorVersion":"unknown","buildID":"unknown","plugins":[{"name":"PDF Viewer","description":"Portable Document Format"},{"name":"Chrome PDF Viewer","description":"Portable Document Format"},{"name":"Chromium PDF Viewer","description":"Portable Document Format"},{"name":"Microsoft Edge PDF Viewer","description":"Portable Document Format"},{"name":"WebKit built-in PDF","description":"Portable Document Format"}],"mimeTypes":[{"type":"application/pdf","suffixes":"pdf","description":"Portable Document Format"},{"type":"text/pdf","suffixes":"pdf","description":"Portable Document Format"}],"screen":{"width":1920,"height":1080,"colorDepth":24,"pixelDepth":24,"orientation":{"type":"landscape-primary","angle":0}},"highEntropyValues":{"architecture":"x86","bitness":"64","brands":[{"brand":"Google Chrome","version":"137"},{"brand":"Chromium","version":"137"},{"brand":"Not/A)Brand","version":"24"}],"mobile":false,"model":"","platform":"Windows","platformVersion":"19.0.0","uaFullVersion":"137.0.7151.119"}};
|
|
7
|
-
|
|
8
4
|
describe("Array Comparison", () => {
|
|
9
5
|
it("should compare two identical arrays", () => {
|
|
10
6
|
const arr1 = [1, 2, 3];
|
|
@@ -16,12 +12,20 @@ describe("Array Comparison", () => {
|
|
|
16
12
|
|
|
17
13
|
it("should compare two different arrays", () => {
|
|
18
14
|
const arr1 = [1, 2, 3];
|
|
19
|
-
const arr2 = [
|
|
15
|
+
const arr2 = [6, 5, 4];
|
|
20
16
|
const result = compareArrays(arr1, arr2);
|
|
21
17
|
console.log("Result:", result);
|
|
22
18
|
expect(result).toEqual([3, 0]); // 3 fields, 0 matches
|
|
23
19
|
});
|
|
24
20
|
|
|
21
|
+
it("should handle shuffled arrays with the same elements", () => {
|
|
22
|
+
const arr1 = [1, 2, 3];
|
|
23
|
+
const arr2 = [3, 2, 1];
|
|
24
|
+
const result = compareArrays(arr1, arr2);
|
|
25
|
+
console.log("Result:", result);
|
|
26
|
+
expect(result).toEqual([3, 3]); // 3 fields, 3 matches
|
|
27
|
+
});
|
|
28
|
+
|
|
25
29
|
it("should handle nested arrays", () => {
|
|
26
30
|
const arr1 = [1, [2, 3], 4];
|
|
27
31
|
const arr2 = [1, [2, 3], 5];
|
|
@@ -47,7 +51,7 @@ describe("Array Comparison", () => {
|
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
it("should handle arrays with undefined values", () => {
|
|
50
|
-
const arr1 = [1,
|
|
54
|
+
const arr1 = [1, 2, undefined];
|
|
51
55
|
const arr2 = [1, 2, 3];
|
|
52
56
|
const result = compareArrays(arr1, arr2);
|
|
53
57
|
console.log("Result:", result);
|
|
@@ -75,18 +79,20 @@ describe("Array Comparison", () => {
|
|
|
75
79
|
const arr2 = [1, [2, [3, [4, [5, [6]]]]]];
|
|
76
80
|
expect(() => compareArrays(arr1, arr2, 0)).toThrow("Max depth exceeded");
|
|
77
81
|
});
|
|
78
|
-
});
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
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);
|
|
83
87
|
console.log("Result:", result);
|
|
84
|
-
expect(result).toEqual([
|
|
88
|
+
expect(result).toEqual([3, 3]); // 3 fields, 3 matches
|
|
85
89
|
});
|
|
86
90
|
|
|
87
|
-
it("should
|
|
88
|
-
const
|
|
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);
|
|
89
95
|
console.log("Result:", result);
|
|
90
|
-
expect(result).toEqual([
|
|
96
|
+
expect(result).toEqual([3, 2]); // 3 fields, 3 matches
|
|
91
97
|
});
|
|
92
98
|
});
|