MCPcopy Create free account
hub / github.com/TanStack/db / parseUuid

Function parseUuid

packages/trailbase-db-collection/e2e/trailbase.e2e.test.ts:40–52  ·  view source on GitHub ↗
(uuid: string)

Source from the content-addressed store, hash-verified

38}
39
40function parseUuid(uuid: string): Uint8Array {
41 const hex = uuid.replace(/-/g, '')
42
43 if (!/^[0-9a-fA-F]{32}$/.test(hex)) {
44 throw new Error(`Invalid UUID: ${uuid}`)
45 }
46
47 return Uint8Array.from(
48 Array.from({ length: 16 }, (_, index) =>
49 Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16),
50 ),
51 )
52}
53
54function stringifyUuid(bytes: Uint8Array): string {
55 if (bytes.length !== 16) {

Callers 1

toTrailBaseIdFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected