mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 17:53:00 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
@@ -1,30 +1,29 @@
|
||||
|
||||
/**
|
||||
* Does a shallow compare of two arrays to determine if they are equal.
|
||||
* @param a1 The first array
|
||||
* @param a2 The second array
|
||||
*/
|
||||
export function compareArrays<T>(a1: T[], a2: T[]): boolean {
|
||||
if (a1.length !== a2.length) {
|
||||
if (a1.length !== a2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < a1.length; ++i) {
|
||||
if (Array.isArray(a1[i])) {
|
||||
// If the other element is not an array, then these cannot be equal
|
||||
if (!Array.isArray(a2[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const elem1 = <any[]>(<any>a1[i]);
|
||||
const elem2 = <any[]>(<any>a2[i]);
|
||||
if (!compareArrays(elem1, elem2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (a1[i] !== a2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < a1.length; ++i) {
|
||||
if (Array.isArray(a1[i])) {
|
||||
// If the other element is not an array, then these cannot be equal
|
||||
if (!Array.isArray(a2[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const elem1 = <any[]><any>a1[i];
|
||||
const elem2 = <any[]><any>a2[i];
|
||||
if (!compareArrays(elem1, elem2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (a1[i] !== a2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user