refactor(simulator): use spread syntax to handle literal arguments
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 May 2023 12:22:45 +0000 (14:22 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 May 2023 12:22:45 +0000 (14:22 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPServiceUtils.ts

index b3c56eb8b963a319ea41e499d31261e9ef0dcbdd..94447bb3930272fc3586778ce43aa49a22ace66e 100644 (file)
@@ -748,7 +748,7 @@ export class ChargingStation {
       terminateOpened: false,
     }
   ): void {
-    options.handshakeTimeout = options?.handshakeTimeout ?? this.getConnectionTimeout() * 1000;
+    options = { handshakeTimeout: this.getConnectionTimeout() * 1000, ...options };
     params = { ...{ closeOpened: false, terminateOpened: false }, ...params };
     if (this.started === false && this.starting === false) {
       logger.warn(
index 01ca8511fd84a1f14de7ed5a15775f1b06c15851..a4702dd6bcf242f3a2eeb234e5e65c985d9452f3 100644 (file)
@@ -363,8 +363,13 @@ export class OCPPServiceUtils {
       unitMultiplier: 1,
     }
   ): number {
-    options.limitationEnabled = options?.limitationEnabled ?? true;
-    options.unitMultiplier = options?.unitMultiplier ?? 1;
+    options = {
+      ...{
+        limitationEnabled: true,
+        unitMultiplier: 1,
+      },
+      ...options,
+    };
     const parsedInt = parseInt(value);
     const numberValue = isNaN(parsedInt) ? Infinity : parsedInt;
     return options?.limitationEnabled