TypeScript UUID
Voici comment générer un UUID standard (généralement v4) en TypeScript. On utilise la bibliothèque standard ou un paquet largement répandu.
Code
const id: string = crypto.randomUUID();
// works in Deno, Bun, Node 19+, browsers
La plupart des langages fournissent v4 (aléatoire) par défaut ; v7 ou ULID peuvent nécessiter une bibliothèque distincte.