export const generateUUID = ( prefix: string = "", suffix: string = "", length: number = 8, ) => { if ( (prefix && typeof prefix !== "string") || (suffix && typeof suffix !== "string") ) { throw new Error("Prefix and suffix must be strings"); } const randomPortion = Math.random() .toString(36) .substring(2, 2 + length); const timestamp = Date.now().toString(36); const formattedPrefix = prefix ? `${prefix}-` : ""; const formattedSuffix = suffix ? `-${suffix}` : ""; const uuid = `${formattedPrefix}${timestamp}${randomPortion}${formattedSuffix}`; return uuid; };