Skip to content

path

Functions

join

ts
join(...parts: string[]): string

Join path segments using the platform separator, normalizing the result.

Parameters:

NameTypeDefault
partsstring[]

Returns: string

(source)

resolve

ts
resolve(...parts: string[]): string

Resolve path segments into an absolute path, relative to the current working directory.

Parameters:

NameTypeDefault
partsstring[]

Returns: string

(source)

basename

ts
basename(p: string, ext: string): string

Return the last portion of a path. If ext is given and the path ends with it, ext is trimmed off.

@param p - The file path @param ext - Extension to strip from the result

Parameters:

NameTypeDefault
pstring
extstring""

Returns: string

(source)

dirname

ts
dirname(p: string): string

Return the directory portion of a path.

Parameters:

NameTypeDefault
pstring

Returns: string

(source)

extname

ts
extname(p: string): string

Return the extension of a path (including the leading dot), or an empty string if there is none.

Parameters:

NameTypeDefault
pstring

Returns: string

(source)

relative

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

Return the relative path from 'from' to 'to'.

@param from - The starting path @param to - The target path

Parameters:

NameTypeDefault
fromstring
tostring

Returns: string

(source)

isAbsolute

ts
isAbsolute(p: string): boolean

Return true if the path is absolute.

Parameters:

NameTypeDefault
pstring

Returns: boolean

(source)