MCPcopy Index your code
hub / github.com/Effect-TS/effect / modify

Function modify

packages/platform/src/internal/keyValueStore.ts:140–153  ·  view source on GitHub ↗
(key: string, f: (value: A) => A)

Source from the content-addressed store, hash-verified

138 const set = (key: string, value: A) => Effect.flatMap(encode(value), (json) => store.set(key, json))
139
140 const modify = (key: string, f: (value: A) => A) =>
141 Effect.flatMap(
142 get(key),
143 (o) => {
144 if (Option.isNone(o)) {
145 return Effect.succeedNone
146 }
147 const newValue = f(o.value)
148 return Effect.as(
149 set(key, newValue),
150 Option.some(newValue)
151 )
152 }
153 )
154
155 return {
156 [SchemaStoreTypeId]: SchemaStoreTypeId,

Callers 1

makeFunction · 0.70

Calls 3

getFunction · 0.70
setFunction · 0.70
fFunction · 0.50

Tested by

no test coverage detected