Contains utility functions for handling paths.
| Function |
Description |
| getFileName |
Gets the file name from the import(dot)meta(dot)url, converting it to a POSIX-style path. |
| getFolderName |
Gets the folder name from the import(dot)meta(dot)url, converting it to a POSIX-style path. |
| isAbsolute |
Determines if a path is absolute. |
| makeFileName |
Makes a file name by appending an extension to a given file name. If the extension is empty, the file name is returned as is. |
| normalizeIfRelative |
Normalizes a given path by ensuring it is relative, adding “./” if necessary. |
| relative |
Returns the relative path from one path to another. path-browserify’s own relative cannot be used directly: it resolves a relative argument against process.cwd(), which on Windows is F:\... rather than a POSIX absolute path, and its slicing then assumes a leading / - so relative('src', '../x') came back as '../..x'. Both arguments are resolved through resolve here instead, and rooted at / before the POSIX comparison. |
| resolve |
Resolves a sequence of paths or path segments into an absolute path. |
| toPosixBuffer |
Converts a buffer containing a path to a POSIX-style buffer by replacing backslashes with forward slashes. |
| toPosixPath |
Converts a given path to a POSIX-style path by replacing backslashes with forward slashes. |
| Variable |
Description |
| basename |
Returns the base name of a file, optionally removing the file extension. |
| delimiter |
A POSIX path delimiter. |
| dirname |
Returns the directory name of a path. directory is used instead of folder to preserve compatibility with node:path module. |
| extname |
Returns the file extension of a path. |
| format |
Formats a path object into a path string. |
| join |
Joins multiple path segments into a single path. |
| normalizePath |
Normalizes a path, resolving ‘..’ and ‘.’ segments. |
| parse |
Parses a path string into a path object. |
| posix |
Provides methods for handling POSIX paths. |
| separator |
A POSIX segment separator. |