Path
Provides path operations through the Effect environment.
The Path service works with file system paths without tying code to one concrete platform module. It exposes common operations such as joining, normalizing, parsing, formatting, resolving, and converting paths to or from file URLs. This module includes the service interface, parsed path type, service tag, runtime marker, and built-in POSIX path layer.
Layers
Other
Services
Service tag for accessing the current Path implementation.
When to use
Use when you need path operations supplied by an effect's environment.
Signature
declare const Path: Service<Path, Path>;Defines the service interface for platform-specific path manipulation.
When to use
Use to depend on path operations through the Effect environment instead of a concrete host path module.
Details
The service exposes operations for joining, normalizing, parsing, formatting, and converting file system paths. URL conversion methods return Effects because invalid file URLs or paths can fail with BadArgument.
Signature
interface Path {
readonly "~effect/platform/Path": "~effect/platform/Path";
readonly basename: (path: string, suffix?: string) => string;
readonly dirname: (path: string) => string;
readonly extname: (path: string) => string;
readonly format: (pathObject: Partial<Path.Parsed>) => string;
readonly fromFileUrl: (url: URL) => Effect<string, BadArgument>;
readonly isAbsolute: (path: string) => boolean;
readonly join: (...paths: readonly Array<string>) => string;
readonly normalize: (path: string) => string;
readonly parse: (path: string) => Parsed;
readonly relative: (from: string, to: string) => string;
readonly resolve: (...pathSegments: readonly Array<string>) => string;
readonly sep: string;
readonly toFileUrl: (path: string) => Effect<URL, BadArgument>;
readonly toNamespacedPath: (path: string) => string;
}Type IDs
Runtime type identifier used to mark implementations of the Path service.
Details
The marker is the exact string stored on Path service implementations. Most code should depend on the Path service instead of inspecting this value directly.
See
layerfor the built-in POSIXPathservice layer
Signature
declare const TypeId: "~effect/platform/Path";
Layer that provides the built-in POSIX
Pathimplementation.When to use
Use when you need an effect that requires the
Pathservice to run with the built-in POSIX path implementation.Details
The layer provides a static service whose separator is
/and whose operations use POSIX path semantics.See
Pathfor accessing thePathservice from an effect