Skip to content
velt/path exports

velt/path

API reference

POSIX 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.

import { join, dirname } from "velt/path";

Exports

function

basename

#std/path/posix.vlt:100

Re-exported from velt/path/posix

function basename(p: string, suffix: string = ""): string

The 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/").

function

dirname

#std/path/posix.vlt:68

Re-exported from velt/path/posix

function dirname(p: string): string

Everything before the last segment ("." if there is none; trailing slashes are ignored).

Re-exported from velt/path/posix

function extname(p: string): string

The extension of the last segment, from its last "." ("" if there is none, or if the only dot starts the name, as in ".bashrc" or "..").

function

isAbsolute

#std/path/posix.vlt:10

Re-exported from velt/path/posix

function isAbsolute(p: string): bool

Whether p starts at the root (with "/").

Re-exported from velt/path/posix

function join(a: string, b: string): string

join(a, b); use joinAll for more parts.

function

joinAll

#std/path/posix.vlt:54

Re-exported from velt/path/posix

function joinAll(parts: string[]): string

Joins the non-empty parts with "/" and normalizes the result ("." if nothing is left).

function

normalize

#std/path/posix.vlt:18

Re-exported from velt/path/posix

function normalize(p: string): string

Resolves "." 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 "/".