MCPcopy Create free account
hub / github.com/Effect-TS/effect / modify

Function modify

packages/effect/src/unstable/persistence/KeyValueStore.ts:785–798  ·  view source on GitHub ↗
(key: string, f: (value: S["Type"]) => S["Type"])

Source from the content-addressed store, hash-verified

783 const set = (key: string, value: S["Type"]) => Effect.flatMap(encode(value), (json) => self.set(key, json))
784
785 const modify = (key: string, f: (value: S["Type"]) => S["Type"]) =>
786 Effect.flatMap(
787 get(key),
788 (o) => {
789 if (Option.isNone(o)) {
790 return Effect.succeedNone
791 }
792 const newValue = f(o.value)
793 return Effect.as(
794 set(key, newValue),
795 Option.some(newValue)
796 )
797 }
798 )
799
800 return {
801 [SchemaStoreTypeId]: SchemaStoreTypeId,

Callers

nothing calls this directly

Calls 4

someMethod · 0.80
getFunction · 0.70
setFunction · 0.70
fFunction · 0.50

Tested by

no test coverage detected