refactor: cleanup isNullOrUndefined usage
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index 448734ba70583b5de1e0997e6e5b618028ab499e..847401013e606759a98dde88ab295a7c6b80e08d 100644 (file)
@@ -12,7 +12,7 @@ import {
   type ResponsePayload,
   ResponseStatus
 } from '../../../types/index.js'
-import { isNotEmptyArray, isNullOrUndefined, logger } from '../../../utils/index.js'
+import { isNotEmptyArray, logger } from '../../../utils/index.js'
 import { Bootstrap } from '../../Bootstrap.js'
 import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel.js'
 import type { AbstractUIServer } from '../AbstractUIServer.js'
@@ -108,9 +108,9 @@ export abstract class AbstractUIService {
         errorDetails: (error as OCPPError).details
       }
     }
-    if (!isNullOrUndefined(responsePayload)) {
+    if (responsePayload != null) {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-      return this.uiServer.buildProtocolResponse(messageId!, responsePayload!)
+      return this.uiServer.buildProtocolResponse(messageId!, responsePayload)
     }
   }
 
@@ -164,7 +164,7 @@ export abstract class AbstractUIService {
     if (isNotEmptyArray(payload.hashIds)) {
       payload.hashIds = payload.hashIds
         ?.map((hashId) => {
-          if (hashId !== undefined && this.uiServer.chargingStations.has(hashId)) {
+          if (hashId != null && this.uiServer.chargingStations.has(hashId)) {
             return hashId
           }
           logger.warn(
@@ -175,7 +175,7 @@ export abstract class AbstractUIService {
           )
           return undefined
         })
-        ?.filter((hashId) => !isNullOrUndefined(hashId)) as string[]
+        ?.filter((hashId) => hashId != null) as string[]
     } else {
       delete payload.hashIds
     }