refactor: use native node random integer generator
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.ts
index bc9a8f436a8c1e7c8b60457f817e9467a6c96933..7ff24ac8a423b7ece4ab779dd87c3972f9dcf2d4 100644 (file)
@@ -1,4 +1,4 @@
-import { getRandomValues, randomBytes, randomInt, randomUUID } from 'node:crypto'
+import { getRandomValues, randomBytes, randomUUID } from 'node:crypto'
 import { env, nextTick } from 'node:process'
 
 import {
@@ -19,7 +19,6 @@ import {
   type TimestampedData,
   WebSocketCloseEventStatusString
 } from '../types/index.js'
-import { Constants } from './Constants.js'
 
 export const logPrefix = (prefixString = ''): string => {
   return `${new Date().toLocaleString()}${prefixString}`
@@ -159,15 +158,6 @@ export const getRandomFloat = (max = Number.MAX_VALUE, min = 0): number => {
   return (randomBytes(4).readUInt32LE() / 0xffffffff) * (max - min) + min
 }
 
-export const getRandomInteger = (max = Constants.MAX_RANDOM_INTEGER, min = 0): number => {
-  max = Math.floor(max)
-  if (min !== 0) {
-    min = Math.ceil(min)
-    return Math.floor(randomInt(min, max + 1))
-  }
-  return Math.floor(randomInt(max + 1))
-}
-
 /**
  * Rounds the given number to the given scale.
  * The rounding is done using the "round half away from zero" method.