Skip to content

Path.isFile() method

pathlib-ts > Path > isFile

Resolves to true when the path points to a regular file (also true for symlinks pointing to regular files).

Signature:

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

Parameter

Type

Description

options

{ followSymlinks?: boolean; }

(Optional) Optional follow-symlink toggle.

Returns:

Promise<boolean>

Promise resolving to true when the path is a regular file.

Follows symlinks by default; pass followSymlinks: false to interrogate the link itself.

Skipping non-files during ingestion

import { Path } from "pathlib-ts";
const uploads = new Path("./uploads");
for (const entry of await uploads.iterdir()) {
if (await entry.isFile()) {
console.log("processing", entry.name);
}
}