parse
function parse(path: string): ParsedPath;
The result carries root, dir, base, name and ext, the same five parts Node's path.parse reports. A part that the path does not have is simply absent from the object, so a bare file name comes back with base, name and ext only.
ext includes the dot, and a name that begins with one — .gitignore — is a name, not an extension.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The path to break apart. |
Returns
ParsedPath — an object with the parts the path has.
Examples
Breaking a path apart
parse("/a/b/c.txt");
// => { root: "/", dir: "/a/b", base: "c.txt", name: "c", ext: ".txt" }
parse("readme.md");
// => { base: "readme.md", name: "readme", ext: ".md" }
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.