Here's the same thing in 200 bytes:
```javascript export function uuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } ```
That's it. RFC 4122 compliant. Version 4 (random). Variant bits correct.
```bash npm install tiny-uuid-gen ```
```javascript import { uuid } from 'tiny-uuid-gen'; const id = uuid(); // "550e8400-e29b-41d4-a716-446655440000" ```
When to use: You just need random IDs and bundle size matters. When NOT to use: Security-critical, need v1/v5, need crypto.getRandomValues().
Sometimes the boring solution is the right one.
GitHub: https://github.com/takawasi/tiny-uuid
---