From: Jérôme Benoit Date: Sun, 30 May 2021 13:24:07 +0000 (+0200) Subject: Simplify code with nullish coalescing X-Git-Tag: v1.0.3-0~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ee6fd7d1fd6f2a15614797fa7e3c2e9794591dbe;p=e-mobility-charging-stations-simulator.git Simplify code with nullish coalescing Signed-off-by: Jérôme Benoit --- 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(); }