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

Function make

packages/effect/src/unstable/persistence/KeyValueStore.ts:224–255  ·  view source on GitHub ↗
(options: MakeOptions)

Source from the content-addressed store, hash-verified

222 * @since 4.0.0
223 */
224export const make = (options: MakeOptions): KeyValueStore =>
225 KeyValueStore.of({
226 [TypeId]: TypeId,
227 has: (key) => Effect.map(options.get(key), Predicate.isNotUndefined),
228 isEmpty: Effect.map(options.size, (size) => size === 0),
229 modify: (key, f) =>
230 Effect.flatMap(
231 options.get(key),
232 (o) => {
233 if (o === undefined) {
234 return Effect.undefined
235 }
236 const newValue = f(o)
237 return Effect.as(
238 options.set(key, newValue),
239 newValue
240 )
241 }
242 ),
243 modifyUint8Array: (key, f) =>
244 Effect.flatMap(
245 options.getUint8Array(key),
246 (o) => {
247 if (o === undefined) {
248 return Effect.undefined
249 }
250 const newValue = f(o)
251 return Effect.as(options.set(key, newValue), newValue)
252 }
253 ),
254 ...options
255 })
256
257/**
258 * Adapts a string-only backing store into a `KeyValueStore`.

Callers 4

makeStringOnlyFunction · 0.70
KeyValueStore.tsFile · 0.70
layerFileSystemFunction · 0.70
layerSqlFunction · 0.70

Calls 5

ofMethod · 0.65
getMethod · 0.65
setMethod · 0.65
fFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected