PurePath.withSuffix() method
pathlib-ts > PurePath > withSuffix
PurePath.withSuffix() method
Section titled “PurePath.withSuffix() method”Return a new path with the file suffix changed. If the path has no suffix, add the given suffix. If the given suffix is an empty string, remove the suffix from the path.
Signature:
withSuffix(suffix: string): PurePath;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
suffix |
string |
New suffix starting with a dot, or an empty string to remove it. |
Returns:
A new path with the updated suffix.
Exceptions
Section titled “Exceptions”The Error class If the suffix does not start with . or the path lacks a stem.
Remarks
Section titled “Remarks”Provide "" to strip the suffix entirely. The argument must start with a dot unless it is empty. Behaviour matches CPython, including validation of empty stems.