mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-15 21:24:48 +00:00
- Rename packages/opencode → packages/tfcode (directory only) - Rename bin/opencode → bin/tfcode (CLI binary) - Rename .opencode → .tfcode (config directory) - Update package.json name and bin field - Update config directory path references (.tfcode) - Keep internal code references as 'opencode' for easy upstream sync - Keep @opencode-ai/* workspace package names This minimal branding approach allows clean merges from upstream opencode repository while providing tfcode branding for users.
24 lines
410 B
TypeScript
24 lines
410 B
TypeScript
export function lazy<T>(fn: () => T) {
|
|
let value: T | undefined
|
|
let loaded = false
|
|
|
|
const result = (): T => {
|
|
if (loaded) return value as T
|
|
try {
|
|
value = fn()
|
|
loaded = true
|
|
return value as T
|
|
} catch (e) {
|
|
// Don't mark as loaded if initialization failed
|
|
throw e
|
|
}
|
|
}
|
|
|
|
result.reset = () => {
|
|
loaded = false
|
|
value = undefined
|
|
}
|
|
|
|
return result
|
|
}
|