Skip to content

Path.stat() method

pathlib-ts > Path > stat

Returns filesystem metadata asynchronously.

Signature:

stat(options?: {
followSymlinks?: boolean;
}): Promise<Stats>;

Parameter

Type

Description

options

{ followSymlinks?: boolean; }

(Optional) Optional follow-symlink toggle.

Returns:

Promise<Stats>

A promise that resolves with fs.Stats information.

Accepts followSymlinks to align with CPython behaviour.

Asserting a directory exists before reading

import { Path } from "pathlib-ts";
const dataDir = new Path("./data");
const stats = await dataDir.stat();
console.log(stats.isDirectory());