This commit is contained in:
Zef Hemel
2023-08-20 18:02:13 +02:00
parent 78ccb2fabc
commit 136682ebd3
3 changed files with 43 additions and 5 deletions
+36
View File
@@ -72,3 +72,39 @@ Loading some onboarding content for you (but doing so does require a working int
return parseYamlSettings(settingsText);
}
// Compares two objects deeply
export function deepEqual(a: any, b: any): boolean {
if (a === b) {
return true;
}
if (typeof a !== typeof b) {
return false;
}
if (typeof a === "object") {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!deepEqual(a[i], b[i])) {
return false;
}
}
return true;
} else {
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
for (const key of aKeys) {
if (!deepEqual(a[key], b[key])) {
return false;
}
}
return true;
}
}
return false;
}