format

import { format } from "jsr:@ende/path";

function

function format(pathObject: Partial<ParsedPath>): string

Generate a path from a ParsedPath object. It does the opposite of parse().

pathObject: Partial<ParsedPath>

Object with path components.

Returns

The formatted path.

Example: Usage

import { format } from "@ende/path/format";
import { assertEquals } from "@ende/assert";

if (Ende.build.os === "windows") {
  assertEquals(format({ dir: "C:\\path\\to", base: "script.ts" }), "C:\\path\\to\\script.ts");
} else {
  assertEquals(format({ dir: "/path/to/dir", base: "script.ts" }), "/path/to/dir/script.ts");
}

Source