Path utilties for operating system file paths that is a re-package of the @std/path module with minor changes to enable it to work in node and bun.
@std/path which is based upon browsify's implementation of path.
Documentation is available on jsr.io
A list of other modules can be found at github.com/bearz-io/js
import { resolve, join, isAbsolute, basename, dirname } from "@bearz/path";
console.log(isAbsolute("./test"));
const dir = resolve("./test");
const file = join(dir, "text.txt");
console.log(dir);
console.log(isAbsolute(dir));
console.log(file);
console.log(dirname(file));
console.log(basename(file))
- basename - Return the last portion of a path.
- common - Determines the common path from a set of paths for the given OS.
- dirname - Return the directory path of a path.
- extname - Return the extension of the path with leading period (".").
- format - Generate a path from a ParsedPath object.
- fromFileUrl - Converts a file URL to a path string.
- globToRegexp - Converts a glob string to a regular expression.
- isAbsolute - Verifies whether provided path is absolute.
- isGlob - Test whether the given string is a glob.
- joinGlobs - Joins a sequence of globs, then normalizes the resulting glob.
- join - Joins a sequence of paths, then normalizes the resulting path.
- normalizeGlob - Normalizes a glob string.
-
normalize - Normalize the path, resolving
'..'
and'.'
segments. - parse - Return an object containing the parsed components of the path.
-
relative - Return the relative path from
from
toto
based on current working direct. - resolve - Resolves path segments into a path.
- toFileUrl - Converts a path string to a file URL.
- toNamespacedPath - Resolves path to a namespace path. This is a no-op on non-windows systems.
@bearz/path is repackaging @std/path to enable it for node/bun and avoid a depdendency on jsr
when shipping @bearz modules to npm avoid issues with shimming between @std/path
and node:path
and include the extra methods such as toFileUrl
and fromFileUrl
.