Overview
Path utilities provide pure string manipulation for file paths without performing any I/O operations. All functions follow POSIX conventions.normalize()
Normalize a path by resolving. and .. segments.
Signature
Usage
isAbsolute()
Check if a path is absolute (starts with/).
Signature
Usage
join()
Join path segments together.Signature
Usage
resolve()
Resolve a sequence of paths into an absolute path.Signature
Parameters
- cwd
string- Current working directory (base path) - segments
string[]- Path segments to resolve
Usage
dirname()
Get the directory name of a path.Signature
Usage
basename()
Get the last portion of a path.Signature
Parameters
- path
string- File path - ext
string- Optional extension to remove
Usage
extname()
Get the extension of a path.Signature
Usage
split()
Split a path into segments.Signature
Usage
Complete Example
Path Patterns
Convert relative to absolute
Get file without extension
Change file extension
Normalize user input
Notes
- All functions perform pure string manipulation (no I/O)
- Follows POSIX conventions (forward slashes)
- Empty path normalizes to
'.' - Absolute paths start with
/ ..segments are resolved relative to current position