close
Skip to main content
Works with
This package works with Cloudflare Workers, Deno, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Browsers
JSR Score94%
Downloads34,506/wk
Published5 months ago (1.1.4)

Utilities for working with file system paths

Functions

f
basename(
path: string | URL,
suffix?: string
): string

Return the last portion of a path.

f
common(paths: string[]): string

Determines the common path from a set of paths for the given OS.

f
dirname(path: string | URL): string

Return the directory path of a path.

f
extname(path: string | URL): string

Return the extension of the path with leading period (".").

f
format(pathObject: Partial<ParsedPath>): string

Generate a path from a ParsedPath object. It does the opposite of parse().

f
fromFileUrl(url: string | URL): string

Converts a file URL to a path string.

f
globToRegExp(
glob: string,
options?: GlobOptions
): RegExp

Converts a glob string to a regular expression.

f
isAbsolute(path: string): boolean

Verifies whether provided path is absolute.

f
isGlob(str: string): boolean

Test whether the given string is a glob.

f
join(
path: string | URL,
...paths: string[]
): string

Joins a sequence of paths, then normalizes the resulting path.

f
joinGlobs(
globs: string[],
options?: GlobOptions
): string

Joins a sequence of globs, then normalizes the resulting glob.

f
normalize(path: string | URL): string

Normalize the path, resolving '..' and '.' segments.

f
normalizeGlob(
glob: string,
options?: GlobOptions
): string

Normalizes a glob string.

f
parse(path: string): ParsedPath

Return an object containing the parsed components of the path.

f
relative(
from: string,
to: string
): string

Return the relative path from from to to based on current working directory.

f
resolve(...pathSegments: string[]): string

Resolves path segments into a path.

f
toFileUrl(path: string): URL

Converts a path string to a file URL.

f
toNamespacedPath(path: string): string

Resolves path to a namespace path. This is a no-op on non-windows systems.

Interfaces

I

Options for globToRegExp, joinGlobs, normalizeGlob and expandGlob.

I

A parsed path object generated by path.parse() or consumed by path.format().

  • base: string

    The file name including extension (if any) such as 'index.html'

  • dir: string

    The full directory path of the parent such as '/home/user/dir' or 'c:\path\dir'

  • ext: string

    The file extension (if any) such as '.html'

  • name: string

    The file name without extension (if any) such as 'index'

  • root: string

    The root of the path such as '/' or 'c:'

Variables

v
DELIMITER: ";" | ":"

The character used to separate entries in the PATH environment variable. On Windows, this is ;. On all other platforms, this is :.

v
SEPARATOR: "\\" | "/"

The character used to separate components of a file path. On Windows, this is \. On all other platforms, this is /.

v
SEPARATOR_PATTERN: RegExp | RegExp

A regular expression that matches one or more path separators.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/path

Import symbol

import * as mod from "@std/path";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/path";