private logPrefix = (connectorId?: number): string => {
return Utils.logPrefix(
` ${this.chargingStation.stationInfo.chargingStationId} | ATG${
- connectorId !== undefined ? ` on connector #${connectorId.toString()}` : ''
+ !Utils.isNullOrUndefined(connectorId) ? ` on connector #${connectorId.toString()}` : ''
}:`
);
};
}
if (
connectorId > 0 &&
- (this.getConnectorStatus(connectorId)?.transactionStarted === undefined ||
- this.getConnectorStatus(connectorId)?.transactionStarted === null)
+ Utils.isNullOrUndefined(this.getConnectorStatus(connectorId)?.transactionStarted)
) {
this.initializeConnectorStatus(connectorId);
}
}
const [uuid, command, requestPayload] = validatedMessageEvent.data as BroadcastChannelRequest;
if (
- requestPayload?.hashIds !== undefined &&
+ !Utils.isNullOrUndefined(requestPayload?.hashIds) &&
requestPayload?.hashIds?.includes(this.chargingStation.stationInfo.hashId) === false
) {
return;
}
- if (requestPayload?.hashId !== undefined) {
+ if (!Utils.isNullOrUndefined(requestPayload?.hashId)) {
logger.error(
`${this.chargingStation.logPrefix()} ${moduleName}.requestHandler: 'hashId' field usage in PDU is deprecated, use 'hashIds' array instead`
);
try {
commandResponse = await this.commandHandler(command, requestPayload);
if (
- commandResponse === undefined ||
- commandResponse === null ||
+ Utils.isNullOrUndefined(commandResponse) ||
Utils.isEmptyObject(commandResponse as CommandResponse)
) {
responsePayload = {
type ResponsePayload,
ResponseStatus,
} from '../types';
-import { logger } from '../utils';
+import { Utils, logger } from '../utils';
const moduleName = 'UIServiceWorkerBroadcastChannel';
status: responsesStatus,
hashIdsSucceeded: this.responses
.get(uuid)
- ?.responses.filter(({ hashId }) => hashId !== undefined)
+ ?.responses.filter(({ hashId }) => !Utils.isNullOrUndefined(hashId))
.map(({ status, hashId }) => {
if (status === ResponseStatus.SUCCESS) {
return hashId;
...(responsesStatus === ResponseStatus.FAILURE && {
hashIdsFailed: this.responses
.get(uuid)
- ?.responses.filter(({ hashId }) => hashId !== undefined)
+ ?.responses.filter(({ hashId }) => !Utils.isNullOrUndefined(hashId))
.map(({ status, hashId }) => {
if (status === ResponseStatus.FAILURE) {
return hashId;
...(responsesStatus === ResponseStatus.FAILURE && {
responsesFailed: this.responses
.get(uuid)
- ?.responses.filter((response) => response !== undefined)
+ ?.responses.filter((response) => !Utils.isNullOrUndefined(response))
.map((response) => {
if (response.status === ResponseStatus.FAILURE) {
return response;
break;
}
}
- const authorizeConnectorIdDefined = authorizeConnectorId !== undefined;
+ const authorizeConnectorIdDefined = !Utils.isNullOrUndefined(authorizeConnectorId);
if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
authorizeConnectorIdDefined &&
(chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = true);
};
} finally {
// Send response for payload not forwarded to broadcast channel
- if (responsePayload !== undefined) {
+ if (!Utils.isNullOrUndefined(responsePayload)) {
this.sendResponse(messageId, responsePayload);
}
}
): void {
if (Utils.isNotEmptyArray(payload.hashIds)) {
payload.hashIds = payload.hashIds
- .filter((hashId) => hashId !== undefined)
+ .filter((hashId) => !Utils.isNullOrUndefined(hashId))
.map((hashId) => {
if (this.uiServer.chargingStations.has(hashId) === true) {
return hashId;
}
public static isCFEnvironment(): boolean {
- return process.env.VCAP_APPLICATION !== undefined;
+ return !Utils.isNullOrUndefined(process.env.VCAP_APPLICATION);
}
public static isIterable<T>(obj: T): boolean {