IndexExtractorclass

new IndexExtractor<I>(source: Extractor<I, TreeElement>, { index = DEFAULT_INDEX }: IndexExtractorOptions = {})
ParamType
sourceExtractor<I, TreeElement>
Upstream extractor that produces the tree-element tree to process. required
optionsIndexExtractorOptions
Options for an IndexExtractor. Defaults to {}
    .indexMatchables
Filename patterns treated as a parent's index. Matched case-insensitively against each child element's key.
- Defaults to README and index files: ["readme.txt", "readme.md", "index.md", "index.ts", "index.tsx"]. readonly
Return
IndexExtractor<I>
Through extractor that absorbs each element's index child into the element itself.

Through extractor that absorbs each element's index child into the element itself.

  • For every element with children: finds the first child whose key matches any index pattern.
  • The matched child's title, description, content, and children are folded into the parent.
  • The matched child is removed from the parent's children list.
  • Purely name-based: it doesn't care whether an element is a directory or a file — any element with children is processed, deepest level first.

Examples

const extractor = new IndexExtractor(new DirectoryExtractor());