Skip to content

Path.iterdirSync() method

pathlib-ts > Path > iterdirSync

Enumerates directory contents synchronously.

Signature:

iterdirSync(options?: {
extra?: {
withFileTypes?: false;
};
}): Path[];

Parameter

Type

Description

options

{ extra?: { withFileTypes?: false; }; }

(Optional) Optional flags controlling the return type.

Returns:

Path[]

Directory entries as Path objects or Dirents.

The UnsupportedOperation When requesting withFileTypes on a runtime without support.

Synchronous variant of Path.iterdir().

Listing child paths synchronously

import { Path } from "pathlib-ts";
const root = new Path("./templates");
for (const entry of root.iterdirSync()) {
console.log(entry.name);
}