MCPcopy Index your code
hub / github.com/anomalyco/opencode / readCurrent

Function readCurrent

packages/app/src/utils/persist.ts:216–231  ·  view source on GitHub ↗
(input: {
  storage: SyncStorage
  key: string
  defaults: unknown
  migrate?: (value: unknown) => unknown
})

Source from the content-addressed store, hash-verified

214}
215
216function readCurrent(input: {
217 storage: SyncStorage
218 key: string
219 defaults: unknown
220 migrate?: (value: unknown) => unknown
221}) {
222 const raw = input.storage.getItem(input.key)
223 if (raw === null) return
224 const next = normalize(input.defaults, raw, input.migrate)
225 if (next === undefined) {
226 input.storage.removeItem(input.key)
227 return null
228 }
229 if (raw !== next) input.storage.setItem(input.key, next)
230 return next
231}
232
233function migrateLegacy(input: {
234 current: SyncStorage

Callers 1

persistedFunction · 0.85

Calls 4

getItemMethod · 0.80
removeItemMethod · 0.80
setItemMethod · 0.80
normalizeFunction · 0.70

Tested by

no test coverage detected