cloudaxe-opencode/packages/opencode/src/util/lazy.ts
Dax Raad f6ed59bf45 Refactor external tools organization and add file search API endpoint
🤖 Generated with [OpenCode](https://opencode.ai)

Co-Authored-By: OpenCode <noreply@opencode.ai>
2025-06-11 23:59:51 -04:00

11 lines
188 B
TypeScript

export function lazy<T>(fn: () => T) {
let value: T | undefined
let loaded = false
return (): T => {
if (loaded) return value as T
value = fn()
return value as T
}
}