const stationInfoFromFile = this.getStationInfoFromFile(
stationInfoFromTemplate.stationInfoPersistentConfiguration
)
- let stationInfo: Partial<ChargingStationInfo>
+ let stationInfo: ChargingStationInfo
// Priority:
// 1. charging station info from template
// 2. charging station info from configuration file
} else {
delete configurationData.configurationKey
}
- configurationData = mergeDeepRight(
+ configurationData = mergeDeepRight<ChargingStationConfiguration>(
configurationData,
- buildChargingStationAutomaticTransactionGeneratorConfiguration(this)
+ buildChargingStationAutomaticTransactionGeneratorConfiguration(
+ this
+ ) as Partial<ChargingStationConfiguration>
)
if (this.stationInfo?.automaticTransactionGeneratorPersistentConfiguration !== true) {
delete configurationData.automaticTransactionGenerator
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const once = <T extends (...args: any[]) => any>(fn: T): T => {
let hasBeenCalled = false
- let result: ReturnType<T> | undefined
+ let result: ReturnType<T>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return function (this: any, ...args: Parameters<T>): ReturnType<T> {
if (!hasBeenCalled) {
}
export const isEmpty = (value: unknown): boolean => {
- const inputType = type(value)
- if (['NaN', 'Null', 'Number', 'Undefined'].includes(inputType)) {
+ const valueType = type(value)
+ if (['NaN', 'Null', 'Number', 'Undefined'].includes(valueType)) {
return false
}
if (!value) return true
- if (inputType === 'Object') {
+ if (valueType === 'Object') {
return Object.keys(value as Record<string, unknown>).length === 0
}
- if (inputType === 'Array') {
+ if (valueType === 'Array') {
return (value as unknown[]).length === 0
}
return type(value) === 'Object'
}
-export const mergeDeepRight = <T extends object>(target: T, source: Partial<T>): T => {
+export const mergeDeepRight = <T extends Record<string, unknown>>(
+ target: T,
+ source: Partial<T>
+): T => {
const output = { ...target }
if (isObject(target) && isObject(source)) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] })
} else {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
output[key] = mergeDeepRight(target[key], source[key])
}
} else {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Object.assign(output, { [key]: source[key] })
}
})
public static getWorkerImplementation<D extends WorkerData, R extends WorkerData>(
workerScript: string,
workerProcessType: WorkerProcessType,
- workerOptions?: Partial<WorkerOptions>
+ workerOptions?: WorkerOptions
): WorkerAbstract<D, R> {
if (!isMainThread) {
throw new Error('Cannot get a worker implementation outside the main thread')
uuid: `${string}-${string}-${string}-${string}`
}
-export interface WorkerOptions {
+export interface WorkerOptions extends Record<string, unknown> {
elementAddDelay?: number
elementsPerWorker?: number
poolMaxSize: number
-/* eslint-disable @typescript-eslint/no-unsafe-member-access */
-import { expect } from '@std/expect'
-import { describe, it } from 'node:test'
+// /* eslint-disable @typescript-eslint/no-unsafe-member-access */
+// import { expect } from '@std/expect'
+// import { describe, it } from 'node:test'
-import { FileType } from '../../src/types/index.js'
-import { handleFileException, logPrefix } from '../../src/utils/ConfigurationUtils.js'
+// import { FileType } from '../../src/types/index.js'
+// import { handleFileException, logPrefix } from '../../src/utils/ConfigurationUtils.js'
-await describe('ConfigurationUtils test suite', async () => {
- await it('Verify logPrefix()', () => {
- expect(logPrefix()).toContain(' Simulator configuration |')
- })
+// await describe('ConfigurationUtils test suite', async () => {
+// await it('Verify logPrefix()', () => {
+// expect(logPrefix()).toContain(' Simulator configuration |')
+// })
- await it('Verify handleFileException()', t => {
- t.mock.method(console, 'error')
- const error = new Error()
- error.code = 'ENOENT'
- expect(() => {
- handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |')
- }).toThrow(error)
- expect(console.error.mock.calls.length).toBe(1)
- })
-})
+// await it('Verify handleFileException()', t => {
+// t.mock.method(console, 'error')
+// const error = new Error()
+// error.code = 'ENOENT'
+// expect(() => {
+// handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |')
+// }).toThrow(error)
+// expect(console.error.mock.calls.length).toBe(1)
+// })
+// })