// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
-import type { Worker } from 'worker_threads'
+import type { Worker } from 'node:worker_threads'
import chalk from 'chalk'
import { EventEmitter } from 'node:events'
getChargingStationChargingProfilesLimit(this)! / this.powerDivider!
const connectorChargingProfilesLimit = getConnectorChargingProfilesLimit(this, connectorId)
return min(
- isNaN(connectorMaximumPower) ? Number.POSITIVE_INFINITY : connectorMaximumPower,
+ Number.isNaN(connectorMaximumPower) ? Number.POSITIVE_INFINITY : connectorMaximumPower,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- isNaN(connectorAmperageLimitationLimit!)
+ Number.isNaN(connectorAmperageLimitationLimit!)
? Number.POSITIVE_INFINITY
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectorAmperageLimitationLimit!,
- isNaN(chargingStationChargingProfilesLimit)
+ Number.isNaN(chargingStationChargingProfilesLimit)
? Number.POSITIVE_INFINITY
: chargingStationChargingProfilesLimit,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- isNaN(connectorChargingProfilesLimit!)
+ Number.isNaN(connectorChargingProfilesLimit!)
? Number.POSITIVE_INFINITY
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectorChargingProfilesLimit!
if (options.limitationEnabled) {
return max(
min(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- (!isNaN(parsedValue) ? parsedValue : Number.POSITIVE_INFINITY) * options.unitMultiplier!,
+ (!Number.isNaN(parsedValue) ? parsedValue : Number.POSITIVE_INFINITY) *
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ options.unitMultiplier!,
maxLimit
),
minLimit
// More efficient time validation function than the one provided by date-fns
export const isValidDate = (date: Date | number | undefined): date is Date | number => {
if (typeof date === 'number') {
- return !isNaN(date)
+ return !Number.isNaN(date)
} else if (isDate(date)) {
- return !isNaN(date.getTime())
+ return !Number.isNaN(date.getTime())
}
return false
}
}
if (typeof value === 'string' || typeof value === 'number') {
const valueToDate = new Date(value)
- if (isNaN(valueToDate.getTime())) {
+ if (Number.isNaN(valueToDate.getTime())) {
throw new Error(`Cannot convert to date: '${value.toString()}'`)
}
return valueToDate
if (typeof value === 'string') {
changedValue = Number.parseInt(value)
}
- if (isNaN(changedValue)) {
+ if (Number.isNaN(changedValue)) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
throw new Error(`Cannot convert to integer: '${value.toString()}'`)
}
if (typeof value === 'string') {
changedValue = Number.parseFloat(value)
}
- if (isNaN(changedValue)) {
+ if (Number.isNaN(changedValue)) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
throw new Error(`Cannot convert to float: '${value.toString()}'`)
}