Skip to content

Commit

Permalink
Update Towns.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Sep 12, 2023
1 parent f72a459 commit e07ec3c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/classes/Towns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,17 @@ class Towns implements Base {
//#region Remove duplicates & add to area
const temp: Record<string, Town> = {}

// townsArray.forEach(a => {
// const name = a.name

// if (temp[name]) temp[name].area += a.area
// else {
// temp[name] = a
// cachedTowns.push(temp[name])
// }
// }, {})

const townsArrLen = townsArray.length
for (let i = 0; i < townsArrLen; i++) {
const town = townsArray[i]
const name = town.name

if (temp[name]) temp[name].area += town.area
else temp[name] = town
else {
temp[name] = town
cachedTowns.push(town)
}
}

cachedTowns = Object.values(temp)
//#endregion

if (cachedTowns.length > 0) {
Expand Down

0 comments on commit e07ec3c

Please sign in to comment.