UCD.js Docs
Path Utils

Pathe Re-exports

Convenience re-exports of pathe functions

Pathe Re-exports

@ucdjs/path-utils re-exports a subset of pathe functions under namespaced names. These are thin wrappers — no additional logic — provided so callers who already depend on @ucdjs/path-utils can avoid adding pathe as a separate dependency.

Exports

ExportEquivalentDescription
patheBasenamepathe.basenameReturns the last portion of a path
patheDirnamepathe.dirnameReturns the directory portion of a path
patheExtnamepathe.extnameReturns the extension of a path
patheJoinpathe.joinJoins path segments
patheNormalizepathe.normalizeNormalizes a path, resolving . and .. segments
patheRelativepathe.relativeReturns the relative path from one path to another
patheResolvepathe.resolveResolves a sequence of paths into an absolute path

Usage

import {
  patheBasename,
  patheDirname,
  patheExtname,
  patheJoin,
  patheNormalize,
  patheRelative,
  patheResolve,
} from '@ucdjs/path-utils';

patheBasename('/home/user/file.txt');       // 'file.txt'
patheDirname('/home/user/file.txt');        // '/home/user'
patheExtname('/home/user/file.txt');        // '.txt'
patheJoin('/home/user', 'docs/file.txt');   // '/home/user/docs/file.txt'
patheNormalize('/home/user/../user/docs');  // '/home/user/docs'
patheRelative('/home/user', '/home/user/docs/file.txt'); // 'docs/file.txt'
patheResolve('/home/user', 'docs/file.txt'); // '/home/user/docs/file.txt'

:::info These functions do not perform any security checks. For user-supplied paths, always use resolveSafePath instead. :::

On this page