@@ -1,26 +0,0 @@
1−export const genUUIDv7Impl = () => {
2− const now = Date.now()
3− const bytes = new Uint8Array(16)
4− crypto.getRandomValues(bytes)
5− // 48-bit timestamp (ms since epoch) in bytes 0-5
6− bytes[0] = (now / 2 ** 40) & 0xff
7− bytes[1] = (now / 2 ** 32) & 0xff
8− bytes[2] = (now / 2 ** 24) & 0xff
9− bytes[3] = (now / 2 ** 16) & 0xff
10− bytes[4] = (now / 2 ** 8) & 0xff
11− bytes[5] = now & 0xff
12− // version 7
13− bytes[6] = (bytes[6] & 0x0f) | 0x70
14− // variant 10xx
15− bytes[8] = (bytes[8] & 0x3f) | 0x80
16− const hex = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('')
17− return (
18− hex.slice(0, 8) + '-' +
19− hex.slice(8, 12) + '-' +
20− hex.slice(12, 16) + '-' +
21− hex.slice(16, 20) + '-' +
22− hex.slice(20, 32)
23− )
24−}
25−
26−export const genUUIDv4Impl = () => crypto.randomUUID()