npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@titan-design/code-parser

v0.1.0

Published

Tree-sitter WASM parsing for TypeScript, TSX and Python, plus the source-file filter and the Extractor contract

Readme

@titan-design/code-parser

Tree-sitter WASM parsing for TypeScript, TSX and Python, plus the source-file filter and the Extractor contract that code analyzers are written against.

Tier 0 of the titan-platform DAG. No @titan-design dependencies. Extracted from @titan-design/code-graph (TP-125), which had ported it byte-for-byte from codewatch's @codewatch/core, so an analyzer can parse source without inheriting ts-morph and a SQLite graph store.

npm install @titan-design/code-parser web-tree-sitter@^0.26.6
import { parseFile, shouldIncludeFile, type Extractor } from "@titan-design/code-parser";

if (shouldIncludeFile("src/greet.py", ["python"])) {
  const file = await parseFile("def greet(name):\n    return name\n", "src/greet.py", "python");
  file.tree.rootNode.type; // "module"
}

const functionSources: Extractor<string> = {
  name: "functions",
  extract: (file) => file.tree.rootNode.descendantsOfType("function_definition").map((n) => n?.text ?? ""),
};

API

  • parseFile(content, filePath, language) returns a ParsedFile (tree, content, filePath, language). language is one of getSupportedLanguages(): typescript, tsx, python. Anything else rejects with Unsupported language: <name>. A .tsx path passed as typescript parses with the tsx grammar, so the filter's answer can be passed straight through; ParsedFile.language stays the name you passed.
  • shouldIncludeFile(path, languages) accepts a path whose extension belongs to one of the languages and that sits under no excluded directory (node_modules, dist, .git, .claude, and others) and matches no excluded pattern (.d.ts, .min.js, lock files).
  • isExcludedDir(name) prunes the same directories during a recursive walk.
  • getLanguageFromPath(path) maps an extension to a filter language, or null. The filter knows typescript (.ts, .tsx) and python (.py). .js and .jsx map to null and never pass shouldIncludeFile, so a walk skips them instead of handing parseFile a file it cannot parse.
  • Extractor<T> is { name, extract(file: ParsedFile): T[] }.

Dependencies

web-tree-sitter is a peer dependency. ParsedFile.tree is a web-tree-sitter Tree, and consumers walk it with web-tree-sitter's Node type, so both sides must see one copy. The grammar packages (tree-sitter-typescript, tree-sitter-python) are regular dependencies: only this package touches them, and it resolves their .wasm files relative to its own installed location. Their native install scripts are not needed; pnpm 10 can leave them unapproved.

Gotchas

  • There is no JavaScript support. Before 0.1.0 the filter accepted .js and .jsx as javascript and parseFile then rejected them; now the filter drops them.
  • The tsx grammar still reports an error for a bare & or a numeric entity (&#128196;) in JSX text. Six of 542 .tsx files in titan-design's packages/ui/src hit this.
  • WASM initialisation and each grammar load happen once per process, on first use.