DirectoryExtractorclass
new DirectoryExtractor({ extractors = DEFAULT_EXTRACTORS, base, ignore = DEFAULT_IGNORE }: DirectoryExtractorOptions = {})| Param | Type | |
|---|---|---|
options | DirectoryExtractorOptions | Options for a directory extractor. Defaults to {} |
.extractors | ImmutableDictionary<FileExtractor> | Extractor dispatch table keyed by file extension (without the leading dot, e.g. "md").- Files with no matching extractor are silently skipped. - Defaults to .md (markdown), .ts / .tsx (TypeScript), and .txt (plain text). readonly |
.base | AbsolutePath | Absolute base path used to resolve relative paths passed to extract(). readonly |
.ignore | Matchables | Glob patterns for entries to skip — applied to both files and directories. - Defaults to test and spec files: ["*.test.ts", "*.test.tsx", "*.spec.ts", "*.spec.tsx"].- Hidden entries ( .-prefixed), underscore-prefixed entries, and node_modules are always skipped on top of these patterns. readonly |
| Return | |
|---|---|
DirectoryExtractor | Extractor that walks a directory on disk and produces a tree of tree-element nodes. |
Extractor that walks a directory on disk and produces a tree of tree-element nodes.
- Recursively descends into subdirectories.
- Dispatches non-ignored files to a matching
FileExtractorbased on extension; files with no matching extractor are silently skipped. - Keys on the produced elements are the verbatim filenames (e.g.
"string.ts","README.md") and directory names (e.g."util"). - This is a pure walker: same-key merging and README absorption are intentionally not applied here — wrap with
MergingExtractor
and/orIndexExtractorto opt in to those behaviours.
Examples
const tree = await new DirectoryExtractor().extract("modules/util");