PHP 8.2.30
Preview: stringify.js Size: 1.43 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/uuid/dist/esm-node/stringify.js

import validate from './validate.js';
/**
 * Convert array of 16 byte values to UUID string format of the form:
 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
 */

const byteToHex = [];

for (let i = 0; i < 256; ++i) {
  byteToHex.push((i + 0x100).toString(16).slice(1));
}

export function unsafeStringify(arr, offset = 0) {
  // Note: Be careful editing this code!  It's been tuned for performance
  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
}

function stringify(arr, offset = 0) {
  const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one
  // of the following:
  // - One or more input array values don't map to a hex octet (leading to
  // "undefined" in the uuid)
  // - Invalid input values for the RFC `version` or `variant` fields

  if (!validate(uuid)) {
    throw TypeError('Stringified UUID is invalid');
  }

  return uuid;
}

export default stringify;

Directory Contents

Dirs: 0 × Files: 16

Name Size Perms Modified Actions
412 B lrw-r--r-- 2026-02-28 00:27:28
Edit Download
281 B lrw-r--r-- 2026-02-28 00:28:04
Edit Download
80 B lrw-r--r-- 2026-02-28 00:28:24
Edit Download
54 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
1.08 KB lrw-r--r-- 2026-02-28 00:28:34
Edit Download
133 B lrw-r--r-- 2026-02-28 00:28:42
Edit Download
323 B lrw-r--r-- 2026-02-28 00:28:48
Edit Download
284 B lrw-r--r-- 2026-02-28 00:28:58
Edit Download
1.43 KB lrw-r--r-- 2026-02-28 00:29:00
Edit Download
3.24 KB lrw-r--r-- 2026-02-28 00:29:06
Edit Download
107 B lrw-r--r-- 2026-02-28 00:29:10
Edit Download
680 B lrw-r--r-- 2026-02-28 00:29:16
Edit Download
110 B lrw-r--r-- 2026-02-28 00:29:22
Edit Download
1.73 KB lrw-r--r-- 2026-02-28 00:29:12
Edit Download
141 B lrw-r--r-- 2026-02-28 00:29:30
Edit Download
200 B lrw-r--r-- 2026-02-28 00:29:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).