From ee6fd7d1fd6f2a15614797fa7e3c2e9794591dbe Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 30 May 2021 15:24:07 +0200 Subject: [PATCH] Simplify code with nullish coalescing 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.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 16415737..8b8091fd 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -816,12 +816,8 @@ export default class ChargingStation { } private openWSConnection(options?: WebSocket.ClientOptions, forceCloseOpened = false): void { - if (Utils.isUndefined(options)) { - options = {} as WebSocket.ClientOptions; - } - if (Utils.isUndefined(options?.handshakeTimeout)) { - options.handshakeTimeout = this.getConnectionTimeout() * 1000; - } + options ?? {} as WebSocket.ClientOptions; + options?.handshakeTimeout ?? this.getConnectionTimeout() * 1000; if (this.isWebSocketOpen() && forceCloseOpened) { this.wsConnection.close(); } -- 2.34.1