Simplify code with nullish coalescing
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 30 May 2021 13:24:07 +0000 (15:24 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 30 May 2021 13:24:07 +0000 (15:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 164157377d7a03c0d5273a662003867046786fe8..8b8091fdbf4e65eb3435e6273bbbbad104e0a747 100644 (file)
@@ -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();
     }