(arr: Uint8Array, offset = 0)
| 41 | } |
| 42 | |
| 43 | function stringify(arr: Uint8Array, offset = 0) { |
| 44 | const uuid = unsafeStringify(arr, offset); |
| 45 | |
| 46 | // Consistency check for valid UUID. If this throws, it's likely due to one |
| 47 | // of the following: |
| 48 | // - One or more input array values don't map to a hex octet (leading to |
| 49 | // "undefined" in the uuid) |
| 50 | // - Invalid input values for the RFC `version` or `variant` fields |
| 51 | if (!validate(uuid)) { |
| 52 | throw TypeError('Stringified UUID is invalid'); |
| 53 | } |
| 54 | |
| 55 | return uuid; |
| 56 | } |
| 57 | |
| 58 | export default stringify; |
no test coverage detected