}
export const sleep = async (milliSeconds: number): Promise<NodeJS.Timeout> => {
- return await new Promise<NodeJS.Timeout>((resolve) =>
+ return await new Promise<NodeJS.Timeout>(resolve =>
setTimeout(resolve as () => void, milliSeconds)
)
}
}
// More efficient time validation function than the one provided by date-fns
-export const isValidTime = (date: unknown): boolean => {
+export const isValidTime = (date: Date | number | undefined): boolean => {
if (typeof date === 'number') {
return !isNaN(date)
} else if (isDate(date)) {
export const getRandomInteger = (max = Constants.MAX_RANDOM_INTEGER, min = 0): number => {
max = Math.floor(max)
- if (min != null && min !== 0) {
+ if (min !== 0) {
min = Math.ceil(min)
return Math.floor(randomInt(min, max + 1))
}
}
export const getRandomFloatRounded = (max = Number.MAX_VALUE, min = 0, scale = 2): number => {
- if (min != null && min !== 0) {
+ if (min !== 0) {
return roundTo(getRandomFloat(max, min), scale)
}
return roundTo(getRandomFloat(max), scale)
}
export const extractTimeSeriesValues = (timeSeries: TimestampedData[]): number[] => {
- return timeSeries.map((timeSeriesItem) => timeSeriesItem.value)
+ return timeSeries.map(timeSeriesItem => timeSeriesItem.value)
}
export const isObject = (item: unknown): boolean => {
}
export const isEmptyObject = (obj: object): boolean => {
- if (obj?.constructor !== Object) {
+ if (obj.constructor !== Object) {
return false
}
// Iterates over the keys of an object, if
}
}
if (
- WebSocketCloseEventStatusString[code as keyof typeof WebSocketCloseEventStatusString] !==
- undefined
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ WebSocketCloseEventStatusString[code as keyof typeof WebSocketCloseEventStatusString] != null
) {
return WebSocketCloseEventStatusString[code as keyof typeof WebSocketCloseEventStatusString]
}
): ((...args: A) => R) => {
let result: R
return (...args: A) => {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (fn != null) {
result = fn.apply<T, A, R>(context, args)
;(fn as unknown as undefined) = (context as unknown as undefined) = undefined