Path.walkSync() method
pathlib-ts > Path > walkSync
Path.walkSync() method
Section titled “Path.walkSync() method”Traverse the directory tree synchronously and return the walk tuples.
Signature:
walkSync(options?: { topDown?: boolean; }): WalkTuple[];Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ topDown?: boolean; } |
(Optional) Control for traversal order ( |
Returns:
An array of WalkTuple entries.
Remarks
Section titled “Remarks”Mirrors Path.walk() but executes synchronously.
Example
Section titled “Example”Summarising a tree synchronously
import { Path } from "pathlib-ts";
const root = new Path("./dist");for (const [dir, dirs, files] of root.walkSync()) { console.log(dir.toString(), dirs.length, files.length);}