close
Skip to main content
This release is versions behind 1.1.5 — 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 Score100%
Downloads90,757/wk
Published3 years ago (0.210.0)

Utilities for working with file system paths

default

Utilities for working with OS-specific file paths.

Functions

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

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

f
common(
paths: string[],
sep?: 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[]): 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
delimiter: ":" | ";"
No documentation available
v
SEP: "/" | "\\"
No documentation available
v
sep: "/" | "\\"
No documentation available
v
SEP_PATTERN: RegExp
No documentation available
v
posix: _posix
No documentation available
v
win32: _windows
No documentation available
basename

Functions

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

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

common

Functions

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

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

dirname

Functions

f
dirname(path: string): string

Return the directory path of a path.

extname

Functions

f
extname(path: string): string

Return the extension of the path with leading period.

format

Functions

f
format(pathObject: FormatInputPathObject): string

Generate a path from FormatInputPathObject object.

from_file_url

Functions

f
fromFileUrl(url: string | URL): string

Converts a file URL to a path string.

glob

Functions

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

Convert a glob string to a regular expression.

f
isGlob(str: string): boolean

Test whether the given string is a glob

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

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

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

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

Interfaces

I

Options for globToRegExp.

Type Aliases

T
GlobToRegExpOptions = GlobOptions & { os?: OSType; }
No documentation available
glob_to_regexp

Functions

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

Convert a glob string to a regular expression.

Type Aliases

T
GlobToRegExpOptions = GlobOptions & { os?: OSType; }
No documentation available
is_absolute

Functions

f
isAbsolute(path: string): boolean

Verifies whether provided path is absolute

is_glob

Functions

f
isGlob(str: string): boolean

Test whether the given string is a glob

join

Functions

f
join(...paths: string[]): string

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

join_globs

Functions

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

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

normalize

Functions

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

normalize_glob

Functions

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

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

parse

Functions

f
parse(path: string): ParsedPath

Return a ParsedPath object of the path.

posix/basename

Functions

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

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

posix/common

Functions

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

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

posix/dirname

Functions

f
dirname(path: string): string

Return the directory path of a path.

posix/extname

Functions

f
extname(path: string): string

Return the extension of the path with leading period.

posix/format

Functions

f
format(pathObject: FormatInputPathObject): string

Generate a path from FormatInputPathObject object.

posix/from_file_url

Functions

f
fromFileUrl(url: URL | string): string

Converts a file URL to a path string.

posix/glob

Functions

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

Convert a glob string to a regular expression.

f
isGlob(str: string): boolean

Test whether the given string is a glob

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

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

f
normalizeGlob(
glob: string,
unnamed 1?: GlobOptions
): string

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

posix/glob_to_regexp

Functions

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

Convert a glob string to a regular expression.

posix/is_absolute

Functions

f
isAbsolute(path: string): boolean

Verifies whether provided path is absolute

posix/is_glob

Functions

f
isGlob(str: string): boolean

Test whether the given string is a glob

posix/join

Functions

f
join(...paths: string[]): string

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

posix/join_globs

Functions

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

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

posix

Utilities for working with OS-specific file paths.

Functions

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

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

f
common(
paths: string[],
sep?: 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: URL | string): 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[]): string

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

f
joinGlobs(
globs: string[],
unnamed 1?: 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,
unnamed 1?: 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

Variables

v
No documentation available
v
SEP: "/"
No documentation available
v
sep: "/"

Utilities for working with OS-specific file paths.

v
SEP_PATTERN: RegExp
No documentation available
posix/normalize

Functions

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

posix/normalize_glob

Functions

f
normalizeGlob(
glob: string,
unnamed 1?: GlobOptions
): string

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

posix/parse

Functions

f
parse(path: string): ParsedPath

Return a ParsedPath object of the path.

posix/relative

Functions

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

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

posix/resolve

Functions

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

Resolves path segments into a path

posix/separator

Variables

v
SEP: "/"
No documentation available
v
SEP_PATTERN: RegExp
No documentation available
posix/to_file_url

Functions

f
toFileUrl(path: string): URL

Converts a path string to a file URL.

posix/to_namespaced_path

Functions

f
toNamespacedPath(path: string): string

Resolves path to a namespace path

relative

Functions

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

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

resolve

Functions

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

Resolves path segments into a path

separator

Variables

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

Functions

f
toFileUrl(path: string): URL

Converts a path string to a file URL.

to_namespaced_path

Functions

f
toNamespacedPath(path: string): string

Resolves path to a namespace path

windows/basename

Functions

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

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

windows/common

Functions

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

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

windows/dirname

Functions

f
dirname(path: string): string

Return the directory path of a path.

windows/extname

Functions

f
extname(path: string): string

Return the extension of the path with leading period.

windows/format

Functions

f
format(pathObject: FormatInputPathObject): string

Generate a path from FormatInputPathObject object.

windows/from_file_url

Functions

f
fromFileUrl(url: URL | string): string

Converts a file URL to a path string.

windows/glob

Functions

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

Convert a glob string to a regular expression.

f
isGlob(str: string): boolean

Test whether the given string is a glob

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

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

f
normalizeGlob(
glob: string,
unnamed 1?: GlobOptions
): string

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

windows/glob_to_regexp

Functions

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

Convert a glob string to a regular expression.

windows/is_absolute

Functions

f
isAbsolute(path: string): boolean

Verifies whether provided path is absolute

windows/is_glob

Functions

f
isGlob(str: string): boolean

Test whether the given string is a glob

windows/join

Functions

f
join(...paths: string[]): string

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

windows/join_globs

Functions

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

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

windows

Utilities for working with OS-specific file paths.

Functions

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

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

f
common(
paths: string[],
sep?: 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: URL | string): 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[]): string

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

f
joinGlobs(
globs: string[],
unnamed 1?: 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,
unnamed 1?: 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

Variables

v
No documentation available
v
SEP: "\\"
No documentation available
v
sep: "\\"

Utilities for working with OS-specific file paths.

v
SEP_PATTERN: RegExp
No documentation available
windows/normalize

Functions

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

windows/normalize_glob

Functions

f
normalizeGlob(
glob: string,
unnamed 1?: GlobOptions
): string

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

windows/parse

Functions

f
parse(path: string): ParsedPath

Return a ParsedPath object of the path.

windows/relative

Functions

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

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

windows/resolve

Functions

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

Resolves path segments into a path

windows/separator

Variables

v
SEP: "\\"
No documentation available
v
SEP_PATTERN: RegExp
No documentation available
windows/to_file_url

Functions

f
toFileUrl(path: string): URL

Converts a path string to a file URL.

windows/to_namespaced_path

Functions

f
toNamespacedPath(path: string): string

Resolves path to a namespace path

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 path from "@std/path";
or

Import directly with a jsr specifier

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