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

Function openFactory

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

Source from the content-addressed store, hash-verified

261 })
262
263const openFactory = (method: string): FileSystem.FileSystem["open"] => {
264 const nodeOpen = effectify(
265 NFS.open,
266 handleErrnoException("FileSystem", method),
267 handleBadArgument(method)
268 )
269 const nodeClose = effectify(
270 NFS.close,
271 handleErrnoException("FileSystem", method),
272 handleBadArgument(method)
273 )
274
275 return (path, options) =>
276 pipe(
277 Effect.acquireRelease(
278 options?.noFollow === true
279 ? Effect.flatMap(noFollowFlags(method, options.flag ?? "r"), (flags) => nodeOpen(path, flags, options.mode))
280 : nodeOpen(path, options?.flag ?? "r", options?.mode),
281 (fd) => Effect.orDie(nodeClose(fd))
282 ),
283 Effect.map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))
284 )
285}
286const open = openFactory("open")
287
288const isEspipe = (error: Error.PlatformError) =>

Callers 1

NodeFileSystem.tsFile · 0.85

Calls 5

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

Tested by

no test coverage detected