UNPKG

983 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8/**
9 * Convert array of 16 byte values to UUID string format of the form:
10 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
11 */
12const byteToHex = [];
13
14for (let i = 0; i < 256; ++i) {
15 byteToHex.push((i + 0x100).toString(16).substr(1));
16}
17
18function bytesToUuid(buf, offset) {
19 const i = offset || 0;
20 const bth = byteToHex; // Note: Be careful editing this code! It's been tuned for performance
21 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
22
23 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();
24}
25
26var _default = bytesToUuid;
27exports.default = _default;
\No newline at end of file