path.ts

view source

Declarations
#

12 declarations

FileFilter
#

path.ts view source

FileFilter import type {FileFilter} from '@fuzdev/fuz_util/path.js';

A filter function for file paths only.

(call)

type (path: string): boolean

path

type string
returns boolean

parse_path_parts
#

path.ts view source

(path: string): string[] import {parse_path_parts} from '@fuzdev/fuz_util/path.js';

path

type string

returns

string[]

examples

parse_path_parts('./foo/bar/baz.ts') // => ['foo', 'foo/bar', 'foo/bar/baz.ts']

parse_path_pieces
#

path.ts view source

(raw_path: string): PathPiece[] import {parse_path_pieces} from '@fuzdev/fuz_util/path.js';

Treats all paths as absolute, so the first piece is always a '/' with type 'separator'.

raw_path

type string

returns

PathPiece[]

parse_path_segments
#

path.ts view source

(path: string): string[] import {parse_path_segments} from '@fuzdev/fuz_util/path.js';

Gets the individual parts of a path, ignoring dots and separators.

path

type string

returns

string[]

examples

parse_path_segments('/foo/bar/baz.ts') // => ['foo', 'bar', 'baz.ts']

PathFilter
#

path.ts view source

PathFilter import type {PathFilter} from '@fuzdev/fuz_util/path.js';

A filter function for paths, can distinguish between files and directories.

(call)

type (path: string, is_directory: boolean): boolean

path

type string

is_directory

type boolean
returns boolean

PathId
#

path.ts view source

PathId import type {PathId} from '@fuzdev/fuz_util/path.js';

An absolute path on the filesystem. Named "id" to be consistent with Rollup.

[key: number]

type string

PathInfo
#

path.ts view source

PathInfo import type {PathInfo} from '@fuzdev/fuz_util/path.js';

Basic information about a filesystem path.

id

type PathId

is_directory

type boolean

PathPiece
#

path.ts view source

PathPiece import type {PathPiece} from '@fuzdev/fuz_util/path.js';

A piece of a parsed path, either a path segment or separator.

ResolvedPath
#

path.ts view source

ResolvedPath import type {ResolvedPath} from '@fuzdev/fuz_util/path.js';

A resolved path with both the original path string and its absolute id.

inheritance

extends: PathInfo

path

type string

should_exclude_path
#

path.ts view source

(filename: string | undefined, exclude: (string | RegExp)[]): boolean import {should_exclude_path} from '@fuzdev/fuz_util/path.js';

Checks if a filename matches any exclusion pattern.

Returns false when filename is undefined, empty string, or exclude is empty. String patterns use substring matching. RegExp patterns use .test().

filename

the file path to check, or undefined for virtual files

type string | undefined

exclude

array of string or RegExp exclusion patterns

type (string | RegExp)[]

returns

boolean

true if the file should be excluded from processing

slugify
#

path.ts view source

(str: string, map_special_characters?: boolean): string import {slugify} from '@fuzdev/fuz_util/path.js';

Converts a string into a URL-compatible slug.

str

type string

map_special_characters

if true, characters like ñ are converted to their ASCII equivalents, runs around 5x faster when disabled

type boolean
default true

returns

string

to_file_path
#

path.ts view source

(path_or_url: string | URL): string import {to_file_path} from '@fuzdev/fuz_util/path.js';

Converts a URL to a file path string, or returns the string as-is.

path_or_url

type string | URL

returns

string

Depends on
#

Imported by
#