Browse packages

Package · v0.1.0

path

Portable path utilities

Browser-safe path utilities with no runtime-native dependencies.

Installation#

bash
npm install @rcompat/path
bash
pnpm add @rcompat/path
bash
yarn add @rcompat/path
bash
bun add @rcompat/path

Usage#

js
import path from "@rcompat/path";

path.posix.normalize("a//b/../c/"); // "a/c/"
path.posix.isAbsolute("/app/routes"); // true
path.relative("C:\\app\\routes", "C:\\app\\assets\\logo.svg");
// "../assets/logo.svg"

relative accepts POSIX and Windows paths and always returns / separators. When the inputs use unrelated roots—such as mixed absolute and relative paths, different Windows drives, or different UNC shares—it returns the normalized target rather than manufacturing a relative path between them.