Last change
on this file since 571e0df was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago |
primeNG components
|
-
Property mode
set to
100644
|
File size:
775 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /**
|
---|
| 2 | * Convert array of 16 byte values to UUID string format of the form:
|
---|
| 3 | * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
---|
| 4 | */
|
---|
| 5 | var byteToHex = [];
|
---|
| 6 | for (var i = 0; i < 256; ++i) {
|
---|
| 7 | byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | function bytesToUuid(buf, offset) {
|
---|
| 11 | var i = offset || 0;
|
---|
| 12 | var bth = byteToHex;
|
---|
| 13 | // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
---|
| 14 | return ([
|
---|
| 15 | bth[buf[i++]], bth[buf[i++]],
|
---|
| 16 | bth[buf[i++]], bth[buf[i++]], '-',
|
---|
| 17 | bth[buf[i++]], bth[buf[i++]], '-',
|
---|
| 18 | bth[buf[i++]], bth[buf[i++]], '-',
|
---|
| 19 | bth[buf[i++]], bth[buf[i++]], '-',
|
---|
| 20 | bth[buf[i++]], bth[buf[i++]],
|
---|
| 21 | bth[buf[i++]], bth[buf[i++]],
|
---|
| 22 | bth[buf[i++]], bth[buf[i++]]
|
---|
| 23 | ]).join('');
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | module.exports = bytesToUuid;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.