From 224a1f849d2515adb39b45bef073cb5bc62fd56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 8 Jun 2023 04:54:13 +0300 Subject: [PATCH] Fix direct search in Stations class --- src/client/classes/Stations.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/client/classes/Stations.ts b/src/client/classes/Stations.ts index 8979505..c8319af 100644 --- a/src/client/classes/Stations.ts +++ b/src/client/classes/Stations.ts @@ -22,7 +22,7 @@ export default class Stations extends Array { .then(this.checkFetchStatus) .then((response: Response) => response.json()); - for (const station of stations){ + for(const station of stations){ this.push(station); if(options.show) logger('Stations', station.name); } @@ -50,15 +50,8 @@ export default class Stations extends Array { if (this === null || !key || !type) return null; if(type == "direct"){ - let foundStation; - for(const station of this){ - if(station.name != key) return null; - foundStation = station; - } - - return foundStation; + return this.find(station => station.name === key); } else { - let foundStations : { station: string, name: string, probability: number }[] = []; if (key == "radio") return null;