From ee0823212862a269e51d223f21012f32b11ffa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 16 Sep 2021 05:35:02 +0300 Subject: [PATCH] Update Stations class --- src/client/classes/Stations.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.js index aa3f444..76493f5 100644 --- a/src/client/classes/Stations.js +++ b/src/client/classes/Stations.js @@ -3,6 +3,7 @@ const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) module.exports = class Stations extends Array { constructor() { + super(); this.logger = require("../funcs/logger.js"); } @@ -15,12 +16,15 @@ module.exports = class Stations extends Array { if(list){ this.logger('Stations'); + this.forEach(oldStation => { + if(list.findIndex(station => station.name == oldStation.name)) return; + delete this[this.findIndex(station => station.name == oldStation.name)]; + }); list.forEach(station => { console.log("- " + station.name); + this.push(station); }); console.log("\n"); - - this = list; } this.logger('Stations', 'Successfully fetched list');