From e07ec3c36c9e6418240456eb084b94ae3145ae31 Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 13 Sep 2023 00:04:46 +0100 Subject: [PATCH] Update Towns.ts --- src/classes/Towns.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/classes/Towns.ts b/src/classes/Towns.ts index 60a2d71..e786165 100644 --- a/src/classes/Towns.ts +++ b/src/classes/Towns.ts @@ -120,26 +120,17 @@ class Towns implements Base { //#region Remove duplicates & add to area const temp: Record = {} - // 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) {