velt/path
API referencePOSIX path manipulation (Node's path.posix) as pure string code. The separator is always / on every platform; the runtime's file functions accept / on Windows too, and a backslash is an ordinary character. For a walkthrough, read the guide.
Exports
suffix if it ends with it, as Node's path.posix.basename has it: a path that is the suffix gives "", a segment that is the suffix stays whole, and a suffix is matched against the segment's characters from its end (Node's algorithm, quirks included: basename("txt/", ".txt") is "txt/").dirnameEverything before the last segment ("." if there is none; trailing slashes are ignored).extnameThe extension of the last segment, from its last "." ("" if there is none, or if the only dot starts the name, as in ".bashrc" or "..").isAbsoluteWhether p starts at the root (with "/").joinjoin(a, b); use joinAll for more parts.joinAllJoins the non-empty parts with "/" and normalizes the result ("." if nothing is left).normalizeResolves "." and ".." segments and collapses repeated slashes; keeps a trailing slash.sepThe path separator: always "/".Re-exported from velt/path/posix
function basename(p: string, suffix: string = ""): stringThe last segment (trailing slashes ignored), without suffix if it ends with it, as Node's
path.posix.basename has it: a path that is the suffix gives "", a segment that is the
suffix stays whole, and a suffix is matched against the segment's characters from its end
(Node's algorithm, quirks included: basename("txt/", ".txt") is "txt/").
Re-exported from velt/path/posix
function dirname(p: string): stringEverything before the last segment ("." if there is none; trailing slashes are ignored).
Re-exported from velt/path/posix
function extname(p: string): stringThe extension of the last segment, from its last "." ("" if there is none, or if the only dot starts the name, as in ".bashrc" or "..").
Re-exported from velt/path/posix
function isAbsolute(p: string): boolWhether p starts at the root (with "/").
Re-exported from velt/path/posix
function join(a: string, b: string): stringjoin(a, b); use joinAll for more parts.
Re-exported from velt/path/posix
function joinAll(parts: string[]): stringJoins the non-empty parts with "/" and normalizes the result ("." if nothing is left).
Re-exported from velt/path/posix
function normalize(p: string): stringResolves "." and ".." segments and collapses repeated slashes; keeps a trailing slash. "" becomes "."; ".." above the root of an absolute path is dropped.
Re-exported from velt/path/posix
const sep = "/"The path separator: always "/".