Constructor
new PurePath(…segments) → {PurePath}
- Description:
Creates a PurePath instance.
- Source:
- See:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
segments |
string | PurePath |
<repeatable> |
Path segments (or canonical path) to create a PurePath with |
Returns:
- A new instance of PurePath.
- Type
- PurePath
Members
name
- Description:
Returns the last part of the path. Equivalent of
node:path.basename(string)
- Source:
Returns the last part of the path. Equivalent of node:path.basename(string)
parent
- Description:
Returns the parent directory path.
- Source:
Returns the parent directory path.
parts
- Description:
Returns an array of path parts.
- Source:
Returns an array of path parts.
path :string
- Description:
The normalized path string.
- Source:
The normalized path string.
Type:
- string
root
- Description:
Returns the root of the path.
- Source:
Returns the root of the path.
stem
- Description:
Returns the file stem (name without suffix).
- Source:
Returns the file stem (name without suffix).
suffix
- Description:
Returns the file extension of the final component, if any.
- Source:
Returns the file extension of the final component, if any.
suffixes
- Description:
Returns an array the path's file extensions.
- Source:
Returns an array the path's file extensions.
Methods
asURI() → {string}
- Description:
Returns the path as a file URI.
- Source:
Returns:
- The file URI.
- Type
- string
isAbsolute() → {boolean}
- Description:
Checks if the path is absolute.
- Source:
Returns:
- True if the path is absolute, otherwise false.
- Type
- boolean
join(…segments) → {PurePath}
- Description:
Joins segments to the PurePath object, creating a new one. Equivalent of
node:path.join
, and pythonpathlib.Path.__div__
.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
segments |
string |
<repeatable> |
segments to join. |
Returns:
- A new PurePath instance representing the joined segments.
- Type
- PurePath
relativeTo(other) → {PurePath}
- Description:
Returns the relative path to another path.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
other |
string | PurePath | The other path to which to calculate the relative path. |
Throws:
-
- If the current path is not relative to the provided path.
- Type
- Error
Returns:
- A new PurePath instance representing the relative path.
- Type
- PurePath
toString() → {string}
- Description:
Returns the path as a string.
- Source:
Returns:
- The path as a string.
- Type
- string
withName(name) → {PurePath}
- Description:
Returns a new path with a different name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The new name for the path. |
Throws:
-
- If the current path has an empty name.
- Type
- Error
Returns:
- A new PurePath instance with the specified name.
- Type
- PurePath
withStem(stem) → {PurePath}
- Description:
Returns a new path with a different stem.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
stem |
string | The new stem for the path. |
Throws:
-
- If the current path has an empty stem.
- Type
- Error
Returns:
- A new PurePath instance with the specified stem.
- Type
- PurePath
withSuffix(value) → {PurePath}
- Description:
Returns a new path with a different suffix.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The new suffix for the path. |
Throws:
-
- If the specified suffix is invalid or if the current path has an empty suffix.
- Type
- Error
Returns:
- A new PurePath instance with the specified suffix.
- Type
- PurePath
withSuffixes(suffixes) → {PurePath}
- Description:
Returns a new path with different suffixes.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
suffixes |
Array.<string> | Array of new suffixes for the path. |
Throws:
-
-
- If suffixes is not an array of strings.
- Type
- TypeError
-
-
-
- If any of the specified suffixes are invalid or if the current path has an empty suffix.
- Type
- Error
-
Returns:
- A new PurePath instance with the specified suffixes.
- Type
- PurePath