From: Jérôme Benoit Date: Sun, 28 May 2023 12:22:45 +0000 (+0200) Subject: refactor(simulator): use spread syntax to handle literal arguments X-Git-Tag: v1.2.15~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=20f0b76c6d1eedd26a7a5d160101233f587ed6c5;p=e-mobility-charging-stations-simulator.git refactor(simulator): use spread syntax to handle literal arguments Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index b3c56eb8..94447bb3 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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( diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 01ca8511..a4702dd6 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -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