source: imaps-frontend/node_modules/uuid/dist/cjs/stringify.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.unsafeStringify = unsafeStringify;
4const validate_js_1 = require("./validate.js");
5const byteToHex = [];
6for (let i = 0; i < 256; ++i) {
7 byteToHex.push((i + 0x100).toString(16).slice(1));
8}
9function unsafeStringify(arr, offset = 0) {
10 return (byteToHex[arr[offset + 0]] +
11 byteToHex[arr[offset + 1]] +
12 byteToHex[arr[offset + 2]] +
13 byteToHex[arr[offset + 3]] +
14 '-' +
15 byteToHex[arr[offset + 4]] +
16 byteToHex[arr[offset + 5]] +
17 '-' +
18 byteToHex[arr[offset + 6]] +
19 byteToHex[arr[offset + 7]] +
20 '-' +
21 byteToHex[arr[offset + 8]] +
22 byteToHex[arr[offset + 9]] +
23 '-' +
24 byteToHex[arr[offset + 10]] +
25 byteToHex[arr[offset + 11]] +
26 byteToHex[arr[offset + 12]] +
27 byteToHex[arr[offset + 13]] +
28 byteToHex[arr[offset + 14]] +
29 byteToHex[arr[offset + 15]]).toLowerCase();
30}
31function stringify(arr, offset = 0) {
32 const uuid = unsafeStringify(arr, offset);
33 if (!(0, validate_js_1.default)(uuid)) {
34 throw TypeError('Stringified UUID is invalid');
35 }
36 return uuid;
37}
38exports.default = stringify;
Note: See TracBrowser for help on using the repository browser.