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

Function openFactory

packages/platform/node-shared/src/NodeFileSystem.ts:195–215  ·  view source on GitHub ↗
(method: string)

Source from the content-addressed store, hash-verified

193// == open
194
195const openFactory = (method: string): FileSystem.FileSystem["open"] => {
196 const nodeOpen = effectify(
197 NFS.open,
198 handleErrnoException("FileSystem", method),
199 handleBadArgument(method)
200 )
201 const nodeClose = effectify(
202 NFS.close,
203 handleErrnoException("FileSystem", method),
204 handleBadArgument(method)
205 )
206
207 return (path, options) =>
208 pipe(
209 Effect.acquireRelease(
210 nodeOpen(path, options?.flag ?? "r", options?.mode),
211 (fd) => Effect.orDie(nodeClose(fd))
212 ),
213 Effect.map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))
214 )
215}
216const open = openFactory("open")
217
218const makeFile = (() => {

Callers 1

NodeFileSystem.tsFile · 0.85

Calls 4

handleErrnoExceptionFunction · 0.90
handleBadArgumentFunction · 0.85
pipeFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected