import { randomUUID } from 'crypto'; export function getRandomInt(min = 0, max = 1000) { const minCeiling = Math.ceil(min); const maxFloor = Math.floor(max); return Math.floor(Math.random() * (maxFloor - minCeiling) + minCeiling); // The maximum is exclusive and the minimum is inclusive } export function getRandomGuid() { return randomUUID(); } export function getRandomBoolean() { const bools = [true, false]; const index = getRandomInt(0, 2); return bools[index]; } export function getRandomString(minLength = 1, maxLength = 100) { const length = getRandomInt(minLength, maxLength + 1); let result = ''; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const charactersLength = characters.length; for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } export function getRandomEnum(type) { const keys = Object.keys(type); return type[keys[getRandomInt(0, keys.length)]]; }