source: imaps-frontend/node_modules/uuid/dist/cjs/v35.js@ 79a0317

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[79a0317]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.URL = exports.DNS = void 0;
4exports.stringToBytes = stringToBytes;
5exports.default = v35;
6const parse_js_1 = require("./parse.js");
7const stringify_js_1 = require("./stringify.js");
8function stringToBytes(str) {
9 str = unescape(encodeURIComponent(str));
10 const bytes = new Uint8Array(str.length);
11 for (let i = 0; i < str.length; ++i) {
12 bytes[i] = str.charCodeAt(i);
13 }
14 return bytes;
15}
16exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
17exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18function v35(version, hash, value, namespace, buf, offset) {
19 const valueBytes = typeof value === 'string' ? stringToBytes(value) : value;
20 const namespaceBytes = typeof namespace === 'string' ? (0, parse_js_1.default)(namespace) : namespace;
21 if (typeof namespace === 'string') {
22 namespace = (0, parse_js_1.default)(namespace);
23 }
24 if (namespace?.length !== 16) {
25 throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
26 }
27 let bytes = new Uint8Array(16 + valueBytes.length);
28 bytes.set(namespaceBytes);
29 bytes.set(valueBytes, namespaceBytes.length);
30 bytes = hash(bytes);
31 bytes[6] = (bytes[6] & 0x0f) | version;
32 bytes[8] = (bytes[8] & 0x3f) | 0x80;
33 if (buf) {
34 offset = offset || 0;
35 for (let i = 0; i < 16; ++i) {
36 buf[offset + i] = bytes[i];
37 }
38 return buf;
39 }
40 return (0, stringify_js_1.unsafeStringify)(bytes);
41}
Note: See TracBrowser for help on using the repository browser.