From 4a56deef7aeca58425c92ec27388bbe34543ad4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 18 Oct 2020 12:19:58 +0200 Subject: [PATCH] Add and use array helper. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.js | 2 +- src/utils/Utils.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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; -- 2.34.1