| 11 | } |
| 12 | |
| 13 | export function unsafeStringify(arr: Uint8Array, offset = 0): string { |
| 14 | // Note: Be careful editing this code! It's been tuned for performance |
| 15 | // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
| 16 | // |
| 17 | // Note to future-self: No, you can't remove the `toLowerCase()` call. |
| 18 | // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351 |
| 19 | return ( |
| 20 | byteToHex[arr[offset + 0]] + |
| 21 | byteToHex[arr[offset + 1]] + |
| 22 | byteToHex[arr[offset + 2]] + |
| 23 | byteToHex[arr[offset + 3]] + |
| 24 | '-' + |
| 25 | byteToHex[arr[offset + 4]] + |
| 26 | byteToHex[arr[offset + 5]] + |
| 27 | '-' + |
| 28 | byteToHex[arr[offset + 6]] + |
| 29 | byteToHex[arr[offset + 7]] + |
| 30 | '-' + |
| 31 | byteToHex[arr[offset + 8]] + |
| 32 | byteToHex[arr[offset + 9]] + |
| 33 | '-' + |
| 34 | byteToHex[arr[offset + 10]] + |
| 35 | byteToHex[arr[offset + 11]] + |
| 36 | byteToHex[arr[offset + 12]] + |
| 37 | byteToHex[arr[offset + 13]] + |
| 38 | byteToHex[arr[offset + 14]] + |
| 39 | byteToHex[arr[offset + 15]] |
| 40 | ).toLowerCase(); |
| 41 | } |
| 42 | |
| 43 | function stringify(arr: Uint8Array, offset = 0) { |
| 44 | const uuid = unsafeStringify(arr, offset); |