X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FSharedLRUCache.ts;h=b58dc79ee6a9509c3fc5a79bf4605487b500d174;hb=abe9e9dd3d72acc384fa2d3acd434f0053d8c61e;hp=97ed4cd1806e9ac45d5a1fd28b52cd1acdc63494;hpb=5a2a53cfa256a32aa342d4dee48492118065e84a;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/SharedLRUCache.ts b/src/charging-station/SharedLRUCache.ts index 97ed4cd1..b58dc79e 100644 --- a/src/charging-station/SharedLRUCache.ts +++ b/src/charging-station/SharedLRUCache.ts @@ -1,18 +1,17 @@ -import LRUCache from 'mnemonist/lru-map-with-delete'; +import LRUCache from 'mnemonist/lru-map-with-delete.js'; -import { Bootstrap } from '../internal'; -import type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration'; -import type { ChargingStationTemplate } from '../types/ChargingStationTemplate'; -import Utils from '../utils/Utils'; +import { Bootstrap } from './internal'; +import type { ChargingStationConfiguration, ChargingStationTemplate } from '../types'; +import { Utils } from '../utils'; enum CacheType { - CHARGING_STATION_TEMPLATE = 'chargingStationTemplate', - CHARGING_STATION_CONFIGURATION = 'chargingStationConfiguration', + chargingStationTemplate = 'chargingStationTemplate', + chargingStationConfiguration = 'chargingStationConfiguration', } type CacheableType = ChargingStationTemplate | ChargingStationConfiguration; -export default class SharedLRUCache { +export class SharedLRUCache { private static instance: SharedLRUCache | null = null; private readonly lruCache: LRUCache; @@ -83,11 +82,11 @@ export default class SharedLRUCache { } private getChargingStationConfigurationKey(hash: string): string { - return `${CacheType.CHARGING_STATION_CONFIGURATION}${hash}`; + return `${CacheType.chargingStationConfiguration}${hash}`; } private getChargingStationTemplateKey(hash: string): string { - return `${CacheType.CHARGING_STATION_TEMPLATE}${hash}`; + return `${CacheType.chargingStationTemplate}${hash}`; } private has(key: string): boolean { @@ -113,7 +112,7 @@ export default class SharedLRUCache { Utils.isNullOrUndefined(chargingStationConfiguration?.configurationKey) === false && Utils.isNullOrUndefined(chargingStationConfiguration?.stationInfo) === false && Utils.isNullOrUndefined(chargingStationConfiguration?.configurationHash) === false && - Utils.isEmptyArray(chargingStationConfiguration?.configurationKey) === false && + Utils.isNotEmptyArray(chargingStationConfiguration?.configurationKey) === true && Utils.isEmptyObject(chargingStationConfiguration?.stationInfo) === false && Utils.isNotEmptyString(chargingStationConfiguration?.configurationHash) === true );