@baeta/util-path
Variables
default
default:
object
Type declaration
Name | Type |
---|---|
( | |
( | |
( | |
( | |
| |
( | |
( | |
( | |
( | |
(... | |
(... | |
( | |
( | |
( | |
( | |
typeof | |
( | |
( | |
( | |
(... | |
| |
( | |
( | |
typeof | |
( |
delimiter
const
delimiter:string
=upath.delimiter
posix
const
posix: typeofposix
=upath.posix
sep
const
sep:string
=upath.sep
win32
const
win32: typeofwin32
=upath.win32
Functions
addExt()
addExt(
file
,ext
):string
Adds .ext to filename, but only if it doesn't already have the exact extension.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
string filename to add extension to |
|
|
string extension to add |
Returns
string
basename()
basename(
p
,ext
?):string
Return the last portion of a path. Similar to the Unix basename command. Often used to extract the file name from a fully qualified path.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the path to evaluate. |
|
|
optionally, an extension to remove from the result. |
Returns
string
changeExt()
changeExt(
filename
,ext
,ignoreExts
?,maxSize
?):string
Changes a filename's extension to ext. If it has no (valid) extension, it adds it.
Valid extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7).
An Array of ignoreExts (eg ['.min']) prevents these from being considered as extension, thus are not changed - the new extension is added instead.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
string filename to change it's extension |
|
|
string extension to change to |
|
|
array extensions to ignore |
|
|
number max length of the extension |
Returns
string
defaultExt()
defaultExt(
filename
,ext
,ignoreExts
?,maxSize
?):string
Adds .ext to filename, only if it doesn't already have any old extension.
(Old) extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7).
An Array of ignoreExts (eg ['.min']) will force adding default .ext even if one of these is present.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
string filename to default to it's extension |
|
|
string extension to default to |
|
|
array extensions to ignore |
|
|
number max length of the extension |
Returns
string
dirname()
dirname(
p
):string
Return the directory name of a path. Similar to the Unix dirname command.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the path to evaluate. |
Returns
string
extname()
extname(
p
):string
Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
Parameters
Parameter | Type | Description |
---|---|---|
|
|
the path to evaluate. |
Returns
string
format()
format(
pathObject
):string
Returns a path string from an object - the opposite of parse().
Parameters
Parameter | Type | Description |
---|---|---|
|
|
path to evaluate. |
Returns
string
isAbsolute()
isAbsolute(
path
):boolean
Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
Parameters
Parameter | Type | Description |
---|---|---|
|
|
path to test. |
Returns
boolean
join()
Call Signature
join(...
paths
):string
Join all arguments together and normalize the resulting path. Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.