// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/**
 * Converts the byte array to a UUID string
 * @param bytes Used to convert Byte to Hex
 */ export function bytesToUuid(bytes) {
  const bits = [
    ...bytes
  ].map((bit)=>{
    const s = bit.toString(16);
    return bit < 0x10 ? "0" + s : s;
  });
  return [
    ...bits.slice(0, 4),
    "-",
    ...bits.slice(4, 6),
    "-",
    ...bits.slice(6, 8),
    "-",
    ...bits.slice(8, 10),
    "-",
    ...bits.slice(10, 16)
  ].join("");
}
/**
 * Converts a string to a byte array by converting the hex value to a number.
 * @param uuid Value that gets converted.
 */ export function uuidToBytes(uuid) {
  const bytes = [];
  uuid.replace(/[a-fA-F0-9]{2}/g, (hex)=>{
    bytes.push(parseInt(hex, 16));
    return "";
  });
  return bytes;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHBzOi8vZGVuby5sYW5kL3N0ZEAwLjIxNy4wL3V1aWQvX2NvbW1vbi50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBDb3B5cmlnaHQgMjAxOC0yMDI0IHRoZSBEZW5vIGF1dGhvcnMuIEFsbCByaWdodHMgcmVzZXJ2ZWQuIE1JVCBsaWNlbnNlLlxuLy8gVGhpcyBtb2R1bGUgaXMgYnJvd3NlciBjb21wYXRpYmxlLlxuXG4vKipcbiAqIENvbnZlcnRzIHRoZSBieXRlIGFycmF5IHRvIGEgVVVJRCBzdHJpbmdcbiAqIEBwYXJhbSBieXRlcyBVc2VkIHRvIGNvbnZlcnQgQnl0ZSB0byBIZXhcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIGJ5dGVzVG9VdWlkKGJ5dGVzOiBudW1iZXJbXSB8IFVpbnQ4QXJyYXkpOiBzdHJpbmcge1xuICBjb25zdCBiaXRzID0gWy4uLmJ5dGVzXS5tYXAoKGJpdCkgPT4ge1xuICAgIGNvbnN0IHMgPSBiaXQudG9TdHJpbmcoMTYpO1x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