import clone from 'just-clone';
-import Constants from './Constants';
-import { WebSocketCloseEventStatusString } from '../types/WebSocket';
+import { Constants } from './internal';
+import { WebSocketCloseEventStatusString } from '../types';
-export default class Utils {
+export class Utils {
private constructor() {
// This is intentional
}
if (max - min === Infinity) {
throw new RangeError('Invalid interval');
}
- const randomPositiveFloat = crypto.randomBytes(4).readUInt32LE() / 0xffffffff;
- return randomPositiveFloat * (max - min) + min;
+ return (crypto.randomBytes(4).readUInt32LE() / 0xffffffff) * (max - min) + min;
}
public static getRandomInteger(max = Constants.MAX_RANDOM_INTEGER, min = 0): number {
}
public static isEmptyArray(object: unknown | unknown[]): boolean {
- if (!Array.isArray(object)) {
+ if (Array.isArray(object) && object.length === 0) {
return true;
}
- if (object.length > 0) {
- return false;
+ return false;
+ }
+
+ public static isNotEmptyArray(object: unknown | unknown[]): boolean {
+ if (Array.isArray(object) && object.length > 0) {
+ return true;
}
- return true;
+ return false;
}
public static isEmptyObject(obj: object): boolean {