( bytes: Uint8Array<ArrayBuffer> )
| 19 | } |
| 20 | |
| 21 | export function bytesToUuid( |
| 22 | bytes: Uint8Array<ArrayBuffer> |
| 23 | ): undefined | string { |
| 24 | if (bytes.byteLength !== UUID_BYTE_SIZE) { |
| 25 | log.warn( |
| 26 | 'bytesToUuid: received an Uint8Array of invalid length. ' + |
| 27 | 'Returning undefined' |
| 28 | ); |
| 29 | return undefined; |
| 30 | } |
| 31 | |
| 32 | const uuids = splitUuids(bytes); |
| 33 | if (uuids.length === 1) { |
| 34 | return uuids[0] || undefined; |
| 35 | } |
| 36 | return undefined; |
| 37 | } |
| 38 | |
| 39 | function splitUuids(buffer: Uint8Array<ArrayBuffer>): Array<string | null> { |
| 40 | const uuids = new Array<string | null>(); |
no test coverage detected