Create a new RelativePath from a string or another RelativePath.
The path is normalized and guaranteed to be relative. Any trailing separator is removed.
Returns the extension of the filename including the leading dot, as a string. If the filename has no extension, returns an empty string.
Note that if the filename starts with a dot (e.g. .gitignore),
that dot is considered part of the stem. So .gitignore has
extension '' and .gitignore.bak has extension .bak
Returns the stem of the filename, i.e. the part before the extension. If the filename has no extension, returns the entire filename
Note that if the filename starts with a dot (e.g. .gitignore),
that dot is considered part of the stem. So .gitignore and
.gitignore.bak both have stem .gitignore
Returns true if this path equals the other path or path string.
Join additional path segments to this path.
Accepts relative path objects and Filename segment arguments for type safety, but you can also directly pass strings for convenience. All args are stringified and interpreted as segments to be joined, regardless of whether they start with a path separator.
Any null, undefined, or empty segments are ignored.
A new instance with the segments appended and resulting path normalized.
Replace the filename extension, keeping the stem the same. The passed string can include or omit the leading dot; if omitted, it will be added.
New extension, e.g. json or .json
A new instance with the filename extension replaced.
Replace the filename (last segment).
A new instance with the filename replaced.
Replace the entire directory path through the parent, while keeping the current filename.
Parent directory as string or another path
A new path rooted at newParent with the same filename.
Replace the filename stem, keeping the extension the same
A new instance with the filename stem replaced.
Returns the string representation of this path.
StaticisChecks whether a string is a relative path. (I.e., if it would be acceptable to the RelativePath constructor.)
The string to check.
true if the string is an absolute path, otherwise false.
Represents a relative path (i.e. a path that doesn't start at the root, i.e. doesn't have a leading separator), and provides methods for path manipulation and queries.
RelativePath is similar to AbsolutePath but lacks methods that are only valid for absolute paths.
Example