From: Jérôme Benoit Date: Sun, 18 Oct 2020 10:19:58 +0000 (+0200) Subject: Add and use array helper. X-Git-Tag: v1.0.1-0~286 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4a56deef7aeca58425c92ec27388bbe34543ad4f;p=e-mobility-charging-stations-simulator.git Add and use array helper. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index 2bed5ff0..f6860786 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -737,7 +737,7 @@ class ChargingStation { } hasAuthorizedTags() { - return Array.isArray(this._authorizedTags) && this._authorizedTags.length > 0; + return !Utils.isEmptyArray(this._authorizedTags); } getRandomTagId() { diff --git a/src/utils/Utils.js b/src/utils/Utils.js index f25f48b2..15ee3071 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -145,6 +145,13 @@ class Utils { } return false; } + + static isEmptyArray(object) { + if (Array.isArray(object) && object.length > 0) { + return false; + } + return true; + } } module.exports = Utils;