Path.existsSync() method
pathlib-ts > Path > existsSync
Path.existsSync() method
Section titled “Path.existsSync() method”Checks for path existence synchronously.
Signature:
existsSync(options?: { followSymlinks?: boolean; }): boolean;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ followSymlinks?: boolean; } |
(Optional) Optional follow-symlink toggle. |
Returns:
boolean
true if the path exists (following symlinks by default).
Remarks
Section titled “Remarks”Supports followSymlinks: false to test dangling links, matching CPython’s API.
Example
Section titled “Example”Guarding a cache file synchronously
import { Path } from "pathlib-ts";
const cache = new Path("./.cache/state.json");if (cache.existsSync()) { console.log("warm cache detected");}