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

@grouchoab/glossary

v0.2.1

Published

Extract glossaries and phrases from Markdown (unigrams + n-grams)

Readme

@grouchoab/glossary

Extract glossaries and phrases from Markdown. Recursively scans a directory for .md/.mdx, tokenizes, and returns a mergeable glossary of terms (unigrams) and phrases (n‑grams) mapped to the files where they occur.

  • Unigrams + phrases: surface concepts like event sourcing or bounded context.
  • Noise controls: stopwords, min token length, min/max document frequency, edge stopword trimming for phrases.
  • Mergeable: combine glossaries from multiple runs/repos without double counting.
  • Pure TS, zero deps.

Install

npm i -D @grouchoab/glossary
# or
pnpm add -D @grouchoab/glossary

Usage

import { extractGlossary, mergeGlossaries } from '@grouchoab/glossary';

const g1 = await extractGlossary('./docs', {
  includePhrases: true,
  ngramMin: 2,
  ngramMax: 3,
  maxDocFreqRatio: 0.8,
});

const g2 = await extractGlossary('./more-docs', {
  includePhrases: false,
});

const combined = mergeGlossaries([g1, g2]);
console.log(JSON.stringify(combined, null, 2));

API

extractGlossary(rootPath: string, options?: ExtractOptions): Promise<Glossary>

Walks rootPath, reads every .md/.mdx, strips Markdown decorations, tokenizes, and returns a JSON‑friendly glossary.

Options (selected):

  • exts: string[] — file extensions to include (default [".md", ".mdx"]).
  • includeHidden: boolean — include dotfiles/directories (default false).
  • stopwords: Iterable<string> — extra stopwords (case‑insensitive unless caseSensitive).
  • minLen: number — minimum token length (default 2).
  • minDocFreq: number — minimum documents containing term (default 1).
  • maxDocFreqRatio: number — drop overly common terms (default 0.85).
  • includePhrases: boolean — include n‑grams (default false).
  • ngramMin/Max: number — n‑gram range (defaults 2..3).
  • dropPhraseEdgesIfStopword: boolean — drop phrases whose first/last token is a stopword (default true).

Return type:

interface Glossary {
  meta: { version: number; createdAt: string; totalDocs: number; rootPaths: string[] };
  terms: Array<{ term: string; docFreq: number; files: string[]; isPhrase?: boolean }>;
}

mergeGlossaries(glossaries: Glossary[]): Glossary

Merges glossaries by unioning file sets per term and recomputing docFreq.

CLI

A small CLI is included:

# index ./docs with phrases (bigrams+trigrams), drop ultra-common terms >80%
npx groucho-glossary ./docs --phrases --max=0.8 > glossary.json

# Or after local install
groucho-glossary ./docs --phrases --max=0.8 > glossary.json

# knobs
--min=<n>      # min document frequency (default 1)
--max=<ratio>  # max document frequency ratio (default 0.85)
--phrases      # include n-grams
--nmin=<n>     # min n for n-grams (default 2)
--nmax=<n>     # max n for n-grams (default 3)

Design Notes

  • Tokenizer strips fenced/inline code, HTML, frontmatter, Markdown punctuation; diacritics removed for stable matching.
  • Stopwords: lightweight English set is built-in; extend via options.stopwords.
  • Phrases: sequential n‑grams over normalized tokens; optional edge stopword drop reduces noise like of the.
  • Combine‑ability: paths in results normalized to forward slashes.

License

MIT