close
Skip to main content
This release is versions behind 1.1.4 — the latest version of @std/path.
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%
Downloads24,027/wk
Published2 years ago (0.206.0)

Utilities for working with file system paths

Functions

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

Return the last portion of a path. Trailing directory separators are ignored, and optional suffix is removed.

f
common(
paths: string[],
sep?
): string

Determines the common path from a set of paths, using an optional separator, which defaults to the OS default separator.

f
dirname(path: string): string

Return the directory path of a path.

f
extname(path: string): string

Return the extension of the path with leading period.

f
format(pathObject: FormatInputPathObject): string

Generate a path from FormatInputPathObject object.

f
fromFileUrl(url: string | URL): string

Converts a file URL to a path string.

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

Convert 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(...paths: string[])

Join all given a sequence of paths,then normalizes the resulting path.

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

Like join(), but doesn't collapse "**/.." when globstar is true.

f
normalize(path: string): string

Normalize the path, resolving '..' and '.' segments. Note that resolving these segments does not necessarily mean that all will be eliminated. A '..' at the top-level will be preserved, and an empty path is canonically '.'.

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

Like normalize(), but doesn't collapse "**/.." when globstar is true.

f
parse(path: string): ParsedPath

Return a ParsedPath object 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

Interfaces

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 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:'

Type Aliases

T
FormatInputPathObject = Partial<ParsedPath>
No documentation available
T
GlobToRegExpOptions = GlobOptions & { os?: OSType; }
No documentation available

Variables

v
No documentation available
v
SEP: "\\" | "/"
No documentation available
v
No documentation available
v
SEP_PATTERN: RegExp | RegExp
No documentation available
v
No documentation available
v
No documentation available

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";