MCPcopy
hub / github.com/uuidjs/uuid / unsafeStringify

Function unsafeStringify

src/stringify.ts:13–41  ·  view source on GitHub ↗
(arr: Uint8Array, offset = 0)

Source from the content-addressed store, hash-verified

11}
12
13export function unsafeStringify(arr: Uint8Array, offset = 0): string {
14 // Note: Be careful editing this code! It's been tuned for performance
15 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
16 //
17 // Note to future-self: No, you can't remove the `toLowerCase()` call.
18 // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
19 return (
20 byteToHex[arr[offset + 0]] +
21 byteToHex[arr[offset + 1]] +
22 byteToHex[arr[offset + 2]] +
23 byteToHex[arr[offset + 3]] +
24 '-' +
25 byteToHex[arr[offset + 4]] +
26 byteToHex[arr[offset + 5]] +
27 '-' +
28 byteToHex[arr[offset + 6]] +
29 byteToHex[arr[offset + 7]] +
30 '-' +
31 byteToHex[arr[offset + 8]] +
32 byteToHex[arr[offset + 9]] +
33 '-' +
34 byteToHex[arr[offset + 10]] +
35 byteToHex[arr[offset + 11]] +
36 byteToHex[arr[offset + 12]] +
37 byteToHex[arr[offset + 13]] +
38 byteToHex[arr[offset + 14]] +
39 byteToHex[arr[offset + 15]]
40 ).toLowerCase();
41}
42
43function stringify(arr: Uint8Array, offset = 0) {
44 const uuid = unsafeStringify(arr, offset);

Callers 9

stringifyFunction · 0.85
v7Function · 0.85
v6ToV1Function · 0.85
v1Function · 0.85
v1ToV6Function · 0.85
_v4Function · 0.85
v6Function · 0.85
v35Function · 0.85
stringify.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected