Extract classes, functions, arrow functions, and imports from a .js/.ts/.tsx/.mts/.cts file.
(path: Path)
| 5859 | |
| 5860 | |
| 5861 | def extract_js(path: Path) -> dict: |
| 5862 | """Extract classes, functions, arrow functions, and imports from a .js/.ts/.tsx/.mts/.cts file.""" |
| 5863 | if path.suffix == ".tsx": |
| 5864 | config = _TSX_CONFIG |
| 5865 | elif path.suffix in (".ts", ".mts", ".cts"): |
| 5866 | config = _TS_CONFIG |
| 5867 | else: |
| 5868 | config = _JS_CONFIG |
| 5869 | result = _extract_generic(path, config) |
| 5870 | if "error" not in result: |
| 5871 | _extract_js_rationale(path, result) |
| 5872 | return result |
| 5873 | |
| 5874 | |
| 5875 | # ── JS/TS rationale + doc-reference extraction ──────────────────────────────── |