formatDurationSeconds,
getWebSocketCloseEventStatusString,
handleFileException,
+ isEmpty,
isNotEmptyArray,
isNotEmptyString,
logger,
public wsConnection: null | WebSocket
public get hasEvses (): boolean {
- return this.connectors.size === 0 && this.evses.size > 0
+ return isEmpty(this.connectors) && this.evses.size > 0
}
public get wsConnectionUrl (): URL {
}
private initializeConnectorsFromTemplate (stationTemplate: ChargingStationTemplate): void {
- if (stationTemplate.Connectors == null && this.connectors.size === 0) {
+ if (stationTemplate.Connectors == null && isEmpty(this.connectors)) {
const errorMsg = `No already defined connectors and charging station information from template ${this.templateFile} with no connectors configuration defined`
logger.error(`${this.logPrefix()} ${errorMsg}`)
throw new BaseError(errorMsg)
)
const connectorsConfigChanged =
this.connectors.size !== 0 && this.connectorsConfigurationHash !== connectorsConfigHash
- if (this.connectors.size === 0 || connectorsConfigChanged) {
+ if (isEmpty(this.connectors) || connectorsConfigChanged) {
connectorsConfigChanged && this.connectors.clear()
this.connectorsConfigurationHash = connectorsConfigHash
if (templateMaxConnectors > 0) {
}
private initializeEvsesFromTemplate (stationTemplate: ChargingStationTemplate): void {
- if (stationTemplate.Evses == null && this.evses.size === 0) {
+ if (stationTemplate.Evses == null && isEmpty(this.evses)) {
const errorMsg = `No already defined evses and charging station information from template ${this.templateFile} with no evses configuration defined`
logger.error(`${this.logPrefix()} ${errorMsg}`)
throw new BaseError(errorMsg)
)
const evsesConfigChanged =
this.evses.size !== 0 && this.evsesConfigurationHash !== evsesConfigHash
- if (this.evses.size === 0 || evsesConfigChanged) {
+ if (isEmpty(this.evses) || evsesConfigChanged) {
evsesConfigChanged && this.evses.clear()
this.evsesConfigurationHash = evsesConfigHash
const templateMaxEvses = getMaxNumberOfEvses(stationTemplate.Evses)
if (this.isWebSocketConnectionOpened() && this.inAcceptedState()) {
this.flushMessageBuffer()
}
- if (!this.isWebSocketConnectionOpened() || this.messageQueue.length === 0) {
+ if (!this.isWebSocketConnectionOpened() || isEmpty(this.messageQueue)) {
this.clearIntervalFlushMessageBuffer()
}
}, Constants.DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL)
import { BaseError } from '../../exception/index.js'
import { Protocol, ProtocolVersion } from '../../types/index.js'
-import { logger, logPrefix } from '../../utils/index.js'
+import { isEmpty, logger, logPrefix } from '../../utils/index.js'
export const getUsernameAndPasswordFromAuthorizationToken = (
authorizationToken: string,
): false | string => {
let protocol: Protocol | undefined
let version: ProtocolVersion | undefined
- if (protocols.size === 0) {
+ if (isEmpty(protocols)) {
return false
}
for (const fullProtocol of protocols) {