personal web client for Bluesky
typescript
solidjs
bluesky
atcute
1const keys = Object.keys;
2
3export const dequal = (a: any, b: any): boolean => {
4 let ctor: any;
5 let len: number;
6
7 if (a === b) {
8 return true;
9 }
10
11 if (a && b && (ctor = a.constructor) === b.constructor) {
12 if (ctor === Array) {
13 if ((len = a.length) === b.length) {
14 while (len--) {
15 if (!dequal(a[len], b[len])) {
16 return false;
17 }
18 }
19 }
20
21 return len === -1;
22 } else if (!ctor || ctor === Object) {
23 len = 0;
24
25 for (ctor in a) {
26 len++;
27
28 if (!(ctor in b) || !dequal(a[ctor], b[ctor])) {
29 return false;
30 }
31 }
32
33 return keys(b).length === len;
34 }
35 }
36
37 return a !== a && b !== b;
38};
39
40export const EQUALS_DEQUAL = { equals: dequal } as const;
41
42export const sequal = (a: any[], b: any[]): boolean => {
43 let len = a.length;
44
45 if (len === b.length) {
46 while (len--) {
47 if (a[len] !== b[len]) {
48 return false;
49 }
50 }
51 }
52
53 return len === -1;
54};