()
| 51 | // Bits 64-65: var=0b10, Bits 66-127: rand_b |
| 52 | |
| 53 | function generateUUIDv7() { |
| 54 | const now = Date.now(); |
| 55 | const msHex = now.toString(16).padStart(12, '0'); |
| 56 | |
| 57 | const bytes = crypto.randomBytes(10); |
| 58 | bytes[0] = (bytes[0] & 0x0f) | 0x70; // version 7 |
| 59 | bytes[2] = (bytes[2] & 0x3f) | 0x80; // variant 10 |
| 60 | |
| 61 | const randHex = bytes.toString('hex'); |
| 62 | |
| 63 | // Standard UUID format: 8-4-4-4-12 (32 hex total) |
| 64 | return [ |
| 65 | msHex.slice(0, 8), |
| 66 | msHex.slice(8, 12), |
| 67 | randHex.slice(0, 4), |
| 68 | randHex.slice(4, 8), |
| 69 | randHex.slice(8, 20), |
| 70 | ].join('-'); |
| 71 | } |
| 72 | |
| 73 | // --- JSONL file helpers --- |
| 74 |
no outgoing calls
no test coverage detected