πŸ“„ File detail

utils/lazySchema.ts

🧩 .tsπŸ“ 9 linesπŸ’Ύ 295 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes lazySchema β€” mainly functions, hooks, or classes. What the file header says: Returns a memoized factory function that constructs the value on first call. Used to defer Zod schema construction from module init time to first access.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Returns a memoized factory function that constructs the value on first call. Used to defer Zod schema construction from module init time to first access.

πŸ“€ Exports (heuristic)

  • lazySchema

πŸ–₯️ Source preview

/**
 * Returns a memoized factory function that constructs the value on first call.
 * Used to defer Zod schema construction from module init time to first access.
 */
export function lazySchema<T>(factory: () => T): () => T {
  let cached: T | undefined
  return () => (cached ??= factory())
}