Path (@std/path)
@std/path manipulates filesystem paths as strings (POSIX / separators). It performs no I/O.
import { join, basename, extname } from "@std/path";
console.log(join(["usr", "local", "bin"])); // usr/local/binconsole.log(basename("/etc/hosts")); // hostsconsole.log(extname("archive.tar.gz")); // .gzNode’s variadic join(...parts) / resolve(...parts) take a string[] here, since Zeus free
functions are not variadic.
Reference
join(parts: string[]): string // join + normalizeresolve(parts: string[]): string // to an absolute path, using process.cwd()normalize(p: string): string // collapse "."/".."/duplicate slashesdirname(p: string): string // directory portionbasename(p: string): string // final segmentextname(p: string): string // extension incl. dot, or ""isAbsolute(p: string): booleanrelative(fromPath: string, toPath: string): stringparse(p: string): ParsedPath // { root, dir, base, ext, name }format(pp: ParsedPath): string // inverse of parsesep(): string // "/"delimiter(): string // ":"import { parse, ParsedPath } from "@std/path";
let pp: ParsedPath = parse("/usr/local/zeus.tar.gz");console.log(pp.dir); // /usr/localconsole.log(pp.base); // zeus.tar.gzconsole.log(pp.ext); // .gzconsole.log(pp.name); // zeus.tar