Function
modify
(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, |
Tested by
no test coverage detected