source: imaps-frontend/node_modules/uuid/dist/esm-browser/stringify.js@ 79a0317

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

F4 Finalna Verzija

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