parse
import { parse } from "jsr:@ende/path";function
function parse(path: string): ParsedPathReturn an object containing the parsed components of the path.
Use format() to reverse
the result.
path: stringPath to process
Returns
An object with the parsed path components.
Example: Usage
import { parse } from "@ende/path/parse";
import { assertEquals } from "@ende/assert";
if (Ende.build.os === "windows") {
const parsedPathObj = parse("C:\\path\\to\\script.ts");
assertEquals(parsedPathObj.root, "C:\\");
assertEquals(parsedPathObj.dir, "C:\\path\\to");
assertEquals(parsedPathObj.base, "script.ts");
assertEquals(parsedPathObj.ext, ".ts");
assertEquals(parsedPathObj.name, "script");
} else {
const parsedPathObj = parse("/path/to/dir/script.ts");
parsedPathObj.root; // "/"
parsedPathObj.dir; // "/path/to/dir"
parsedPathObj.base; // "script.ts"
parsedPathObj.ext; // ".ts"
parsedPathObj.name; // "script"
}