()
| 3 | } |
| 4 | |
| 5 | export function generateUID(): string { |
| 6 | if ('randomUUID' in crypto) { |
| 7 | const uuid = crypto.randomUUID(); |
| 8 | return uuid.substring(0, 8) + uuid.substring(9, 13) + uuid.substring(14, 18) + uuid.substring(19, 23) + uuid.substring(24); |
| 9 | } |
| 10 | |
| 11 | if ('getRandomValues' in crypto) { |
| 12 | return Array.from((crypto as Crypto).getRandomValues(new Uint8Array(16))).map((x) => hexify(x)).join(''); |
| 13 | } |
| 14 | |
| 15 | return Math.floor(Math.random() * 2 ** 55).toString(36); |
| 16 | } |
no test coverage detected