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

Function generateId

packages/db-collection-e2e/src/fixtures/seed-data.ts:9–21  ·  view source on GitHub ↗

* Generate deterministic valid UUIDs for testing

(prefix: string, index: number)

Source from the content-addressed store, hash-verified

7 * Generate deterministic valid UUIDs for testing
8 */
9function generateId(prefix: string, index: number): string {
10 const key = `${prefix}-${index}`
11 if (!uuidCache.has(key)) {
12 // Generate a real UUID but make it deterministic for the same prefix+index
13 const hex = index.toString(16).padStart(8, `0`)
14 // Create a valid UUID v4 format
15 uuidCache.set(
16 key,
17 `${hex.slice(0, 8)}-0000-4000-8000-${hex.padStart(12, `0`)}`,
18 )
19 }
20 return uuidCache.get(key)!
21}
22
23/**
24 * Generate seed data with proper distributions for testing

Callers 1

generateSeedDataFunction · 0.70

Calls 4

hasMethod · 0.45
toStringMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected