};
export const sleep = async (milliSeconds: number): Promise<NodeJS.Timeout> => {
- return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds));
+ return new Promise<NodeJS.Timeout>((resolve) => setTimeout(resolve as () => void, milliSeconds));
};
export const formatDurationMilliSeconds = (duration: number): string => {
return value;
}
if (isString(value) || typeof value === 'number') {
- return new Date(value);
+ return new Date(value!);
}
return null;
};
changedValue = parseInt(value as string);
}
if (isNaN(changedValue)) {
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
throw new Error(`Cannot convert to integer: ${value.toString()}`);
}
return changedValue;
changedValue = parseFloat(value as string);
}
if (isNaN(changedValue)) {
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
throw new Error(`Cannot convert to float: ${value.toString()}`);
}
return changedValue;
};
export const isIterable = <T>(obj: T): boolean => {
- return !isNullOrUndefined(obj) ? typeof obj[Symbol.iterator] === 'function' : false;
+ return !isNullOrUndefined(obj) ? typeof obj[Symbol.iterator as keyof T] === 'function' : false;
};
const isString = (value: unknown): boolean => {
): string => {
return JSON.stringify(
obj,
- (key, value: Record<string, unknown>) => {
+ (_, value: Record<string, unknown>) => {
if (value instanceof Map) {
return {
dataType: 'Map',
return '(For applications)';
}
}
- if (!isUndefined(WebSocketCloseEventStatusString[code])) {
- return WebSocketCloseEventStatusString[code] as string;
+ if (
+ !isUndefined(
+ WebSocketCloseEventStatusString[code as keyof typeof WebSocketCloseEventStatusString],
+ )
+ ) {
+ return WebSocketCloseEventStatusString[code as keyof typeof WebSocketCloseEventStatusString];
}
return '(Unknown)';
};