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

Function withKeyPath

packages/platform/src/internal/keyValueStore.ts:200–213  ·  view source on GitHub ↗
(
        method: string,
        key: string,
        f: (path: string) => Effect.Effect<A, PlatformError.PlatformError>
      )

Source from the content-addressed store, hash-verified

198 const fs = yield* FileSystem.FileSystem
199 const path = yield* Path.Path
200 const withKeyPath = <A>(
201 method: string,
202 key: string,
203 f: (path: string) => Effect.Effect<A, PlatformError.PlatformError>
204 ): Effect.Effect<A, PlatformError.PlatformError> =>
205 key.length === 0 || key === "." || key === ".."
206 ? Effect.fail(
207 new PlatformError.BadArgument({
208 module: "KeyValueStore",
209 method,
210 description: "Key must not be empty, . or .."
211 })
212 )
213 : f(path.join(directory, encodeURIComponent(key)))
214
215 if (!(yield* fs.exists(directory))) {
216 yield* fs.makeDirectory(directory, { recursive: true })

Callers 1

layerFileSystemFunction · 0.85

Calls 3

failMethod · 0.65
joinMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected