MCPcopy Create free account
hub / github.com/anomalyco/opencode / write

Function write

packages/app/src/utils/persist.ts:143–164  ·  view source on GitHub ↗
(storage: Storage, key: string, value: string)

Source from the content-addressed store, hash-verified

141}
142
143function write(storage: Storage, key: string, value: string) {
144 try {
145 storage.setItem(key, value)
146 cacheSet(key, value)
147 return true
148 } catch (error) {
149 if (!quota(error)) throw error
150 }
151
152 try {
153 storage.removeItem(key)
154 cacheDelete(key)
155 storage.setItem(key, value)
156 cacheSet(key, value)
157 return true
158 } catch (error) {
159 if (!quota(error)) throw error
160 }
161
162 const ok = evict(storage, key, value)
163 return ok
164}
165
166function snapshot(value: unknown) {
167 return JSON.parse(JSON.stringify(value)) as unknown

Callers 3

localStorageWithPrefixFunction · 0.70
localStorageDirectFunction · 0.70
runFunction · 0.70

Calls 6

cacheSetFunction · 0.85
quotaFunction · 0.85
cacheDeleteFunction · 0.85
setItemMethod · 0.80
removeItemMethod · 0.80
evictFunction · 0.70

Tested by

no test coverage detected