Path.glob() method
pathlib-ts > Path > glob
Path.glob() method
Section titled “Path.glob() method”Globs files within this subtree asynchronously. Iterate over this subtree and yields all existing files (of any kind, including directories) matching the given relative pattern.
Signature:
glob(pattern: string, options?: fs.GlobOptions): Promise<Path[]>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
pattern |
string |
Glob pattern interpreted relative to this path. |
|
options |
fs.GlobOptions |
(Optional) Options forwarded to Node’s |
Returns:
Promise<Path[]>
Promise resolving to matching Path objects.
Exceptions
Section titled “Exceptions”The UnsupportedOperation If globbing is not supported.
Remarks
Section titled “Remarks”Matches CPython behaviour but relies on fs.glob. Throws UnsupportedOperation when the runtime lacks glob support. Options are forwarded to the underlying Node implementation.
Example
Section titled “Example”Awaiting glob results for documentation
import { Path } from "pathlib-ts";
const docs = new Path("./docs");const pages = await docs.glob("**.md");console.log(pages.map((page) => page.name));