refactor(simulator): sort exports
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.ts
index ab2a8a5f26302bf23d52aa3bf0a21e407d29ace8..bac9705da1ba8e37f67418f86aebbc630529595e 100644 (file)
@@ -3,10 +3,10 @@ import util from 'node:util';
 
 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
   }
@@ -128,8 +128,7 @@ export default class Utils {
     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 {
@@ -215,13 +214,17 @@ export default class Utils {
   }
 
   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 {