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

@lexbuild/core

v1.9.4

Published

Core AST definitions, parsing infrastructure, and format-agnostic renderers for the LexBuild ecosystem.

Readme

@lexbuild/core

npm license

This package is part of the LexBuild monorepo, a tool that converts U.S. legal XML into structured Markdown optimized for AI, RAG pipelines, and semantic search. See the monorepo for full documentation, architecture details, and contribution guidelines.

It provides the foundational building blocks for XML parsing infrastructure, AST definitions, and Markdown rendering for use by all source packages (@lexbuild/usc, @lexbuild/ecfr) and @lexbuild/cli.

Install

npm install @lexbuild/core

What's Included

XML Parser

Streaming SAX parser with namespace normalization. Supports USLM (U.S. Code) and namespace-free XML (eCFR) via the defaultNamespace option.

import { XMLParser } from "@lexbuild/core";

const parser = new XMLParser();
parser.on("openElement", (name, attrs) => { /* ... */ });
parser.on("closeElement", (name) => { /* ... */ });
parser.on("text", (text) => { /* ... */ });

await parser.parseStream(readableStream);

USLM AST Builder

Stack-based XML-to-AST construction with a section-emit pattern for bounded memory usage. This builder handles USLM 1.0 XML (U.S. Code). Source packages for other formats (e.g., @lexbuild/ecfr) provide their own builders.

import { ASTBuilder } from "@lexbuild/core";

const builder = new ASTBuilder({
  emitAt: "section",
  onEmit: (node, context) => {
    // Called with each completed section subtree
  },
});

Markdown Renderer

Stateless AST-to-Markdown conversion with YAML frontmatter, cross-reference link resolution, and notes filtering.

import { renderDocument, generateFrontmatter, createLinkResolver } from "@lexbuild/core";

const markdown = renderDocument(sectionNode, frontmatterData, {
  linkStyle: "relative",
  resolveLink: resolver.resolve,
});

AST Node Types

Full type definitions for the legal document AST: LevelNode, ContentNode, InlineNode, NoteNode, TableNode, SourceType, LegalStatus, and more.

import type { ASTNode, LevelNode, FrontmatterData, SourceType, LegalStatus } from "@lexbuild/core";

Namespace Constants

USLM, XHTML, Dublin Core namespace URIs and element classification sets.

import { USLM_NS, XHTML_NS, LEVEL_ELEMENTS, CONTENT_ELEMENTS } from "@lexbuild/core";

API Reference

| Export | Description | |--------|-------------| | XMLParser | Streaming SAX parser with namespace normalization | | ASTBuilder / UslmASTBuilder | USLM XML events to AST with section-emit pattern | | renderDocument() | Render a section node with frontmatter to Markdown | | renderSection() | Render a section-level node to Markdown | | renderNode() | Render any AST node to Markdown | | generateFrontmatter() | Generate YAML frontmatter block | | createLinkResolver() | Create a cross-reference link resolver | | parseIdentifier() | Parse a USC or CFR identifier into components | | FORMAT_VERSION | Output format version ("1.1.0") | | GENERATOR | Generator string for frontmatter |

License

MIT