close
Skip to main content

@std/path@1.1.6
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score100%
License
MIT
Downloads87,560/wk
Published20 hours ago (1.1.6)

Utilities for working with file system paths

Utilities for working with Windows-specific paths.

import { fromFileUrl } from "@std/path/windows/from-file-url";
import { assertEquals } from "@std/assert";

assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");

Functions

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

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

f
common(paths: string[]): string

Determines the common path from a set of paths for Windows systems.

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 ParsedPath object.

f
fromFileUrl(url: URL | string): string

Converts a file URL to a path string.

f
globToRegExp(
glob: string,
options?: GlobOptions
): 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
isGlob(str: string): boolean

Test whether the given string is a glob.

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

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

f
joinGlobs(
globs: string[],
options?: Pick<GlobOptions, "globstar">
): string

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

f
normalize(path: string | URL): 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?: Pick<GlobOptions, "globstar">
): 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

Options for globToRegExp, joinGlobs, normalizeGlob and expandGlob.

Type Aliases

T
FormatInputPathObject = Partial<ParsedPath>
No documentation available

Variables

v

The character used to separate entries in the PATH environment variable.

v
SEPARATOR: "\\"

The character used to separate components of a file path.

v

A regular expression that matches one or more path separators.