Skip to content

Commit

Permalink
Fix reduce on empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Apr 2, 2024
1 parent 0afe073 commit 0715bba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,10 @@ async function buildMarkerMap(bulletins: AvalancheBulletin[]) {
popup.show(e.coordinate, formatBulletin(regionID, bulletin));
return;
}
const aws = eawsOutlineProperties
.filter((p) => regionID.startsWith(p.id))
.reduce((a, b) => (a.id.length > b.id.length ? a : b));
if (aws) {
popup.show(e.coordinate, formatEawsOutline(aws));
const aws = eawsOutlineProperties.filter((p) => regionID.startsWith(p.id));
if (aws.length) {
const a = aws.reduce((a, b) => (a.id.length > b.id.length ? a : b));
popup.show(e.coordinate, formatEawsOutline(a));
return;
}
});
Expand Down

0 comments on commit 0715bba

Please sign in to comment.