Function format

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

    Parameters

    • pathObject: Partial<ParsedPath>

      Object with path components.

    Returns string

    The formatted path.

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

    if (Deno.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");
    }