Path.iterdirStream() method
pathlib-ts > Path > iterdirStream
Path.iterdirStream() method
Section titled “Path.iterdirStream() method”Streams directory entries lazily using async iteration without materialising the entire directory listing.
Signature:
iterdirStream(options?: { extra?: { withFileTypes?: false; }; }): AsyncIterable<Path>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ extra?: { withFileTypes?: false; }; } |
(Optional) Optional flags controlling the yielded value type. |
Returns:
AsyncIterable<Path>
An async iterable yielding Path objects or Dirents.
Exceptions
Section titled “Exceptions”The UnsupportedOperation When requesting withFileTypes without runtime support.
Remarks
Section titled “Remarks”Shares the same extra.withFileTypes behaviour as Path.iterdir(). Uses fs.opendir when available to avoid materialising the whole directory; otherwise falls back to buffered reads. Throws UnsupportedOperation when withFileTypes is requested but not supported.
Example
Section titled “Example”Streaming a large media folder
import { Path } from "pathlib-ts";
const media = new Path("/var/media");for await (const entry of media.iterdirStream()) { if (await entry.isFile()) { console.log(entry.name); }}