MCPcopy Index your code
hub / github.com/Effect-TS/effect / openFactory

Function openFactory

packages/platform-node-shared/src/internal/fileSystem.ts:170–190  ·  view source on GitHub ↗
(method: string)

Source from the content-addressed store, hash-verified

168// == open
169
170const openFactory = (method: string) => {
171 const nodeOpen = effectify(
172 NFS.open,
173 handleErrnoException("FileSystem", method),
174 handleBadArgument(method)
175 )
176 const nodeClose = effectify(
177 NFS.close,
178 handleErrnoException("FileSystem", method),
179 handleBadArgument(method)
180 )
181
182 return (path: string, options?: FileSystem.OpenFileOptions) =>
183 pipe(
184 Effect.acquireRelease(
185 nodeOpen(path, options?.flag ?? "r", options?.mode),
186 (fd) => Effect.orDie(nodeClose(fd))
187 ),
188 Effect.map((fd) => makeFile(FileSystem.FileDescriptor(fd), options?.flag?.startsWith("a") ?? false))
189 )
190}
191const open = openFactory("open")
192
193const makeFile = (() => {

Callers 2

fileSystem.tsFile · 0.85
makeTempFileFactoryFunction · 0.85

Calls 5

handleErrnoExceptionFunction · 0.85
handleBadArgumentFunction · 0.85
mapMethod · 0.65
effectifyFunction · 0.50
pipeFunction · 0.50

Tested by

no test coverage detected