Path.expandUser() method
pathlib-ts > Path > expandUser
Path.expandUser() method
Section titled “Path.expandUser() method”Return a new path with expanded ~ and ~user constructs.
Signature:
expandUser(): Promise<Path>;Returns:
Promise<Path>
Promise resolving to a Path with user-home prefixes expanded.
Exceptions
Section titled “Exceptions”The Error class When the home directory cannot be determined.
Remarks
Section titled “Remarks”Uses the current platform home directory lookup to mirror CPython semantics.
Example
Section titled “Example”Expanding a user directory asynchronously
import { Path } from "pathlib-ts";
const downloads = await new Path("~/Downloads").expandUser();console.log(downloads.toString());