source dump of claude code
at main 8 lines 295 B view raw
1/** 2 * Returns a memoized factory function that constructs the value on first call. 3 * Used to defer Zod schema construction from module init time to first access. 4 */ 5export function lazySchema<T>(factory: () => T): () => T { 6 let cached: T | undefined 7 return () => (cached ??= factory()) 8}