pathnamespacenamespace pathPaths, on node:path (commons 0001-system FR-003): the platform's own rules, and posix and win32 for the other's, with file: URLs both ways. Taken from Stolos's src/archon/core/path.ts, which already used node:path; it replaces @std/path.
import { basename, join } from "./path.ts";
basename(join("a", "b", "c.txt")); // "c.txt"pathnamespacenamespace pathpath.joinconstno test imports itconst join: (...paths: string[]) => stringPath segments joined and normalized.
path.dirnameconstno test imports itconst dirname: (path: string) => stringThe folder a path is in.
path.basenameconstno test imports itconst basename: (path: string, suffix?: string | undefined) => stringThe last segment of a path, without suffix where it ends with it.
path.extnameconstno test imports itconst extname: (path: string) => stringThe extension of the last segment, with its dot (.ts), or "".
path.relativeconstno test imports itconst relative: (from: string, to: string) => stringThe path from one to the other.
path.resolveconstno test imports itconst resolve: (...paths: string[]) => stringAn absolute path, the segments taken from the right until one is absolute, against the working folder.
path.normalizeconstno test imports itconst normalize: (path: string) => stringA path with . and .. and repeated separators resolved.
path.isAbsoluteconstno test imports itconst isAbsolute: (path: string) => booleanWhether a path is absolute.
path.parseconstno test imports itconst parse: (path: string) => ParsedPathA path's root, folder, base, name and extension.
path.formatconstno test imports itconst format: (parts: FormatInputPathObject) => stringA path made from its parts.
path.sepconstno test imports itconst sep: stringThis platform's separator between segments: /, or \ on Windows.
path.delimiterconstno test imports itconst delimiter: stringThis platform's separator between paths in PATH: :, or ; on Windows.
path.posixconstno test imports itconst posix: typeof pathThe POSIX rules, on any platform.
path.win32constno test imports itconst win32: typeof pathThe Windows rules, on any platform.
path.fromFileUrlfunctionno test imports itfunction fromFileUrl(url: string | URL): stringA file: URL as a path.
path.toFileUrlfunctionno test imports itfunction toFileUrl(path: string): URLA path as a file: URL.
path.toPosixfunctionno test imports itfunction toPosix(path: string): stringA path with / between its segments whatever the platform, as archives and URLs write them.
joinconstconst join: (...paths: string[]) => stringPath segments joined and normalized.
dirnameconstconst dirname: (path: string) => stringThe folder a path is in.
basenameconstconst basename: (path: string, suffix?: string | undefined) => stringThe last segment of a path, without suffix where it ends with it.
extnameconstno test imports itconst extname: (path: string) => stringThe extension of the last segment, with its dot (.ts), or "".
relativeconstno test imports itconst relative: (from: string, to: string) => stringThe path from one to the other.
resolveconstconst resolve: (...paths: string[]) => stringAn absolute path, the segments taken from the right until one is absolute, against the working folder.
normalizeconstno test imports itconst normalize: (path: string) => stringA path with . and .. and repeated separators resolved.
isAbsoluteconstno test imports itconst isAbsolute: (path: string) => booleanWhether a path is absolute.
parseconstno test imports itconst parse: (path: string) => ParsedPathA path's root, folder, base, name and extension.
formatconstno test imports itconst format: (parts: FormatInputPathObject) => stringA path made from its parts.
sepconstno test imports itconst sep: stringThis platform's separator between segments: /, or \ on Windows.
delimiterconstconst delimiter: stringThis platform's separator between paths in PATH: :, or ; on Windows.
posixconstconst posix: typeof pathThe POSIX rules, on any platform.
win32constconst win32: typeof pathThe Windows rules, on any platform.
fromFileUrlfunctionfunction fromFileUrl(url: string | URL): stringA file: URL as a path.
toFileUrlfunctionfunction toFileUrl(path: string): URLA path as a file: URL.
toPosixfunctionfunction toPosix(path: string): stringA path with / between its segments whatever the platform, as archives and URLs write them.