Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

v35.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = _default;
  6. exports.URL = exports.DNS = void 0;
  7. var _bytesToUuid = _interopRequireDefault(require("./bytesToUuid.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function uuidToBytes(uuid) {
  10. // Note: We assume we're being passed a valid uuid string
  11. var bytes = [];
  12. uuid.replace(/[a-fA-F0-9]{2}/g, function (hex) {
  13. bytes.push(parseInt(hex, 16));
  14. });
  15. return bytes;
  16. }
  17. function stringToBytes(str) {
  18. str = unescape(encodeURIComponent(str)); // UTF8 escape
  19. var bytes = new Array(str.length);
  20. for (var i = 0; i < str.length; i++) {
  21. bytes[i] = str.charCodeAt(i);
  22. }
  23. return bytes;
  24. }
  25. const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
  26. exports.DNS = DNS;
  27. const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
  28. exports.URL = URL;
  29. function _default(name, version, hashfunc) {
  30. var generateUUID = function (value, namespace, buf, offset) {
  31. var off = buf && offset || 0;
  32. if (typeof value == 'string') value = stringToBytes(value);
  33. if (typeof namespace == 'string') namespace = uuidToBytes(namespace);
  34. if (!Array.isArray(value)) throw TypeError('value must be an array of bytes');
  35. if (!Array.isArray(namespace) || namespace.length !== 16) throw TypeError('namespace must be uuid string or an Array of 16 byte values'); // Per 4.3
  36. var bytes = hashfunc(namespace.concat(value));
  37. bytes[6] = bytes[6] & 0x0f | version;
  38. bytes[8] = bytes[8] & 0x3f | 0x80;
  39. if (buf) {
  40. for (var idx = 0; idx < 16; ++idx) {
  41. buf[off + idx] = bytes[idx];
  42. }
  43. }
  44. return buf || (0, _bytesToUuid.default)(bytes);
  45. }; // Function#name is not settable on some platforms (#270)
  46. try {
  47. generateUUID.name = name;
  48. } catch (err) {} // For CommonJS default export support
  49. generateUUID.DNS = DNS;
  50. generateUUID.URL = URL;
  51. return generateUUID;
  52. }