PurePath.relativeTo() method
pathlib-ts > PurePath > relativeTo
PurePath.relativeTo() method
Section titled “PurePath.relativeTo() method”Return the relative path to another path identified by the passed arguments.
Signature:
relativeTo(other: PathLike, options?: { walkUp?: boolean; }): PurePath;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
other |
Anchor path used as the reference point. | |
|
options |
{ walkUp?: boolean; } |
(Optional) Optional lexical behaviour toggles ( |
Returns:
A new path relative to other.
Exceptions
Section titled “Exceptions”The Error class When anchors differ or no lexical relationship exists (and walkUp is false).
Remarks
Section titled “Remarks”By default the operation is purely lexical and raises if the target is not an ancestor. Pass options.walkUp = true to allow .. segments. This mirrors CPython and is the foundation for Path.relativeTo policies.