Skip to content

Commit

Permalink
try with set
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith committed Dec 28, 2024
1 parent ddc0c1e commit 7449bab
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/src/lib/components/Forms/AutocompleteSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@
function arraysEqual(arr1: (string | undefined)[], arr2: (string | undefined)[]) {
if (arr1?.length !== arr2?.length) return false;
const sortedArr1 = [...arr1].sort();
const sortedArr2 = [...arr2].sort();
const set1 = new Set(arr1);
const set2 = new Set(arr2);
return sortedArr1.every((value, index) => value === sortedArr2[index]);
if (set1.size !== set2.size) return false;
for (const value of set1) {
if (!set2.has(value)) return false;
}
return true;
}
$: {
Expand Down

0 comments on commit 7449bab

Please sign in to comment.