Skip to content

Commit

Permalink
use toReversed
Browse files Browse the repository at this point in the history
  • Loading branch information
hankxdev committed Sep 27, 2024
1 parent 8f07e7b commit ec5ca66
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions source/extension.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,15 @@
size *= window.devicePixelRatio;
if (icons) {
const sortedIcons = icons.sort(sortIconBySize);
// Get a large icon closest to the desired size
for (const icon of sortedIcons) {
for (const icon of icons.toReversed()) {
if (icon.size >= size) {
return icon.url;
}
}
// Fallback icon
return 'icons/puzzle.svg';
}
// Fallback icon
return 'icons/puzzle.svg';
}
function sortIconBySize(a, b) {
return b.size - a.size;
}
</script>
Expand Down

0 comments on commit ec5ca66

Please sign in to comment.