perf: minimize OCPPUtils exports
[e-mobility-charging-stations-simulator.git] / src / charging-station / ConfigurationKeyUtils.ts
index 39606b66e1ea8d08cacc61b53d58607d53d9c73d..d1d093f7e978d832453b1bc1e585460d2e09f227 100644 (file)
@@ -33,12 +33,8 @@ export const addConfigurationKey = (
   chargingStation: ChargingStation,
   key: ConfigurationKeyType,
   value: string,
-  options: ConfigurationKeyOptions = {
-    readonly: false,
-    visible: true,
-    reboot: false,
-  },
-  params: AddConfigurationKeyParams = { overwrite: false, save: false },
+  options?: ConfigurationKeyOptions,
+  params?: AddConfigurationKeyParams,
 ): void => {
   options = {
     ...{
@@ -50,13 +46,13 @@ export const addConfigurationKey = (
   };
   params = { ...{ overwrite: false, save: false }, ...params };
   let keyFound = getConfigurationKey(chargingStation, key);
-  if (keyFound && params?.overwrite) {
+  if (keyFound !== undefined && params?.overwrite === true) {
     deleteConfigurationKey(chargingStation, keyFound.key, {
       save: false,
     });
     keyFound = undefined;
   }
-  if (!keyFound) {
+  if (keyFound === undefined) {
     chargingStation.ocppConfiguration?.configurationKey?.push({
       key,
       readonly: options.readonly!,
@@ -80,7 +76,7 @@ export const setConfigurationKeyValue = (
   caseInsensitive = false,
 ): void => {
   const keyFound = getConfigurationKey(chargingStation, key, caseInsensitive);
-  if (keyFound) {
+  if (keyFound !== undefined) {
     chargingStation.ocppConfiguration!.configurationKey![
       chargingStation.ocppConfiguration!.configurationKey!.indexOf(keyFound)
     ].value = value;
@@ -96,11 +92,11 @@ export const setConfigurationKeyValue = (
 export const deleteConfigurationKey = (
   chargingStation: ChargingStation,
   key: ConfigurationKeyType,
-  params: DeleteConfigurationKeyParams = { save: true, caseInsensitive: false },
+  params?: DeleteConfigurationKeyParams,
 ): ConfigurationKey[] | undefined => {
   params = { ...{ save: true, caseInsensitive: false }, ...params };
   const keyFound = getConfigurationKey(chargingStation, key, params?.caseInsensitive);
-  if (keyFound) {
+  if (keyFound !== undefined) {
     const deletedConfigurationKey = chargingStation.ocppConfiguration?.configurationKey?.splice(
       chargingStation.ocppConfiguration.configurationKey.indexOf(keyFound),
       1,