dirname
import { dirname } from "jsr:@ende/path";function
function dirname(path: string | URL): stringReturn the directory path of a path.
path: string | URLPath to extract the directory from. When passed as a
URLinstance, its protocol must befile:. For other protocols, pass the URL as a string or pass itspathnameproperty.
Returns
The directory path.
Example: Usage
import { dirname } from "@ende/path/dirname";
import { assertEquals } from "@ende/assert";
if (Ende.build.os === "windows") {
assertEquals(dirname("C:\\home\\user\\Documents\\image.png"), "C:\\home\\user\\Documents");
assertEquals(dirname(new URL("file:///C:/home/user/Documents/image.png")), "C:\\home\\user\\Documents");
} else {
assertEquals(dirname("/home/user/Documents/image.png"), "/home/user/Documents");
assertEquals(dirname(new URL("file:///home/user/Documents/image.png")), "/home/user/Documents");
}