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/usc

v1.10.0

Published

Federal U.S. Code specific element handlers and downloader for LexBuild

Downloads

2,188

Readme

@lexbuild/usc

npm license

Converts official USLM XML from the Office of the Law Revision Counsel (OLRC) into structured Markdown optimized for AI, RAG pipelines, and semantic search. Includes a downloader that auto-detects the latest OLRC release point.

Tip: For command-line usage, install @lexbuild/cli instead. This package is the programmatic API.

Install

npm install @lexbuild/usc
# or
pnpm add @lexbuild/usc

Peer dependency: @lexbuild/core (installed automatically via workspace protocol in the monorepo).

Quick Start

Download and Convert

import { downloadTitles, convertTitle } from "@lexbuild/usc";

// Download Title 1 (auto-detects latest OLRC release point)
const download = await downloadTitles({
  outputDir: "./downloads/usc/xml",
  titles: [1],
});
console.log(`Release point: ${download.releasePoint}`);

// Convert to section-level Markdown
const result = await convertTitle({
  input: "./downloads/usc/xml/usc01.xml",
  output: "./output",
  granularity: "section",
  linkStyle: "plaintext",
  includeSourceCredits: true,
  includeNotes: true,
  includeEditorialNotes: false,
  includeStatutoryNotes: false,
  includeAmendments: false,
  dryRun: false,
});

console.log(`${result.sectionsWritten} sections, ${result.totalTokenEstimate} est. tokens`);

Release Point Detection

import { detectLatestReleasePoint } from "@lexbuild/usc";

const info = await detectLatestReleasePoint();
if (info) {
  console.log(`Latest: ${info.releasePoint}`); // e.g., "119-80"
  console.log(`Description: ${info.description}`); // e.g., "Public Law 119-80 (03/15/2026)"
}

Pin a Specific Release Point

const result = await downloadTitles({
  outputDir: "./downloads/usc/xml",
  releasePoint: "119-73not60", // Override auto-detection
});

API Reference

Functions

| Export | Description | |--------|-------------| | convertTitle(options) | Convert a USC XML file to Markdown at any granularity | | downloadTitles(options) | Download USC XML from OLRC (auto-detects latest release point) | | detectLatestReleasePoint() | Scrape the OLRC download page for the current release point | | buildDownloadUrl(titleNumber, releasePoint) | Build download URL for a single title zip | | buildAllTitlesUrl(releasePoint) | Build download URL for the bulk all-titles zip | | releasePointToPath(releasePoint) | Convert "119-73not60""119/73not60" | | isAllTitles(titles) | Check if a title list covers all 54 USC titles |

Types

| Export | Description | |--------|-------------| | ConvertOptions | Options for convertTitle() — input, output, granularity, link style, note filters | | ConvertResult | Conversion result — sections written, chapters, files, token estimate, memory | | DownloadOptions | Options for downloadTitles() — output dir, titles, optional release point | | DownloadResult | Download result — release point used, files, errors | | DownloadedFile | Single downloaded file metadata (title number, path, size) | | DownloadError | Failed download metadata (title number, error message) | | ReleasePointInfo | Detected release point with human-readable description |

Constants

| Export | Description | |--------|-------------| | FALLBACK_RELEASE_POINT | Hardcoded fallback used when auto-detection fails | | USC_TITLE_NUMBERS | Array of valid title numbers [1, 2, ..., 54] |

Output

Each title produces Markdown files with YAML frontmatter. The structure depends on granularity:

| Granularity | Output Path | Sidecar Files | |---|---|---| | section (default) | usc/title-01/chapter-01/section-1.md | _meta.json per chapter + title, README.md per title | | chapter | usc/title-01/chapter-01/chapter-01.md | _meta.json per title, README.md per title | | title | usc/title-01.md | Enriched frontmatter only |

Data Source

XML is downloaded from the OLRC at uscode.house.gov. Release points are published multiple times per month as new public laws are enacted. The downloader auto-detects the latest release point from the OLRC download page; use --release-point (CLI) or releasePoint (API) to pin a specific version.

Compatibility

  • Node.js >= 22
  • ESM only — no CommonJS build
  • TypeScript — ships .d.ts type declarations

Monorepo Context

Part of the LexBuild monorepo. Depends on @lexbuild/core for XML parsing, AST types, and Markdown rendering.

pnpm turbo build --filter=@lexbuild/usc
pnpm turbo test --filter=@lexbuild/usc

Related Packages

| Package | Description | |---------|-------------| | @lexbuild/cli | CLI tool — the easiest way to use LexBuild | | @lexbuild/core | Shared parsing, AST, and rendering infrastructure | | @lexbuild/ecfr | eCFR (Code of Federal Regulations) converter |

License

MIT