mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-25 03:34:22 +01:00
ignore: cloud stuff
This commit is contained in:
11
cloud/core/src/util/memo.ts
Normal file
11
cloud/core/src/util/memo.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function memo<T>(fn: () => T) {
|
||||
let value: T | undefined
|
||||
let loaded = false
|
||||
|
||||
return (): T => {
|
||||
if (loaded) return value as T
|
||||
loaded = true
|
||||
value = fn()
|
||||
return value as T
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user