1 |
|
2 |
|
3 |
|
4 |
|
5 | const byteToHex = [];
|
6 |
|
7 | for (let i = 0; i < 256; ++i) {
|
8 | byteToHex.push((i + 0x100).toString(16).substr(1));
|
9 | }
|
10 |
|
11 | function bytesToUuid(buf, offset) {
|
12 | const i = offset || 0;
|
13 | const bth = byteToHex;
|
14 |
|
15 |
|
16 | return (bth[buf[i + 0]] + bth[buf[i + 1]] + bth[buf[i + 2]] + bth[buf[i + 3]] + '-' + bth[buf[i + 4]] + bth[buf[i + 5]] + '-' + bth[buf[i + 6]] + bth[buf[i + 7]] + '-' + bth[buf[i + 8]] + bth[buf[i + 9]] + '-' + bth[buf[i + 10]] + bth[buf[i + 11]] + bth[buf[i + 12]] + bth[buf[i + 13]] + bth[buf[i + 14]] + bth[buf[i + 15]]).toLowerCase();
|
17 | }
|
18 |
|
19 | export default bytesToUuid; |
\ | No newline at end of file |