const pickRandomN = (N:number):number => Math.floor(Math.random() * N); export function generateHandle(): string { const adjectives = [ "swift", "quiet", "bright", "clever", "calm", "bold", "lucky", "mighty", ]; const nouns = [ "otter", "falcon", "panda", "tiger", "raven", "wolf", "gecko", "badger", ]; const adjective = adjectives[pickRandomN(adjectives.length)]; const noun = nouns[pickRandomN(nouns.length)]; const suffix = crypto.randomUUID().slice(0, 4); // The UUID suffix makes collisions extremely unlikely. // For strict uniqueness among active users, // also check the generated handle against the currently connected handles and regenerate on collision. return `${adjective}-${noun}-${suffix}`; }