| 16 | import * as NodeUrl from "node:url" |
| 17 | |
| 18 | const fileUrlOps = (windows: boolean | undefined) => ({ |
| 19 | fromFileUrl: (url: URL): Effect.Effect<string, BadArgument> => |
| 20 | Effect.try({ |
| 21 | try: () => NodeUrl.fileURLToPath(url, { windows }), |
| 22 | catch: (cause) => |
| 23 | new BadArgument({ |
| 24 | module: "Path", |
| 25 | method: "fromFileUrl", |
| 26 | cause |
| 27 | }) |
| 28 | }), |
| 29 | toFileUrl: (path: string): Effect.Effect<URL, BadArgument> => |
| 30 | Effect.try({ |
| 31 | try: () => NodeUrl.pathToFileURL(path, { windows }), |
| 32 | catch: (cause) => |
| 33 | new BadArgument({ |
| 34 | module: "Path", |
| 35 | method: "toFileUrl", |
| 36 | cause |
| 37 | }) |
| 38 | }) |
| 39 | }) |
| 40 | |
| 41 | /** |
| 42 | * Provides the `Path` service using Node's POSIX path implementation plus |