std/path/format.ts
Ooker 8b90e3154c
docs(path): add more details to ParsedPath and other examples (#4489)
* docs: add detailed info on the ParsedPath interface

* docs: add detailed info on the ParsedPath interface

* docs: add examples of path/basename.ts

* fmt

* fix

* fix type error

* formatting nits

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-03-16 15:32:20 +10:00

18 lines
615 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import { isWindows } from "./_os.ts";
import { format as posixFormat } from "./posix/format.ts";
import { format as windowsFormat } from "./windows/format.ts";
import type { FormatInputPathObject } from "./_interface.ts";
/**
* Generate a path from `FormatInputPathObject` object. It does the opposite
* of `parse`.
*
* @param pathObject with path
*/
export function format(pathObject: FormatInputPathObject): string {
return isWindows ? windowsFormat(pathObject) : posixFormat(pathObject);
}