Path.iterdirSync() method
pathlib-ts > Path > iterdirSync
Path.iterdirSync() method
Section titled “Path.iterdirSync() method”Enumerates directory contents synchronously.
Signature:
iterdirSync(options?: { extra?: { withFileTypes?: false; }; }): Path[];Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ extra?: { withFileTypes?: false; }; } |
(Optional) Optional flags controlling the return type. |
Returns:
Path[]
Directory entries as Path objects or Dirents.
Exceptions
Section titled “Exceptions”The UnsupportedOperation When requesting withFileTypes on a runtime without support.
Remarks
Section titled “Remarks”Synchronous variant of Path.iterdir().
Example
Section titled “Example”Listing child paths synchronously
import { Path } from "pathlib-ts";
const root = new Path("./templates");for (const entry of root.iterdirSync()) { console.log(entry.name);}