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

123456789101112131415161718
  1. /**
  2. * Convert array of 16 byte values to UUID string format of the form:
  3. * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  4. */
  5. var byteToHex = [];
  6. for (var i = 0; i < 256; ++i) {
  7. byteToHex[i] = (i + 0x100).toString(16).substr(1);
  8. }
  9. function bytesToUuid(buf, offset) {
  10. var i = offset || 0;
  11. var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
  12. return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join('');
  13. }
  14. export default bytesToUuid;