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

@tty-pt/lemma

v1.2.2

Published

Universal Node.js and Browser bindings for liblemma Lexical Search & Unicode Accent Folding

Readme

@tty-pt/lemma

npm version License: BSD-2-Clause TypeScript Ready Node.js Native WebAssembly Zero Dependencies

Universal Node.js and Browser bindings for liblemma, the pure-C lexical tokenization, Unicode case-folding, and full-text search engine. Represents the canonical Text Axis in the Corm Recall Kernel.


1. Quickstart

npm install @tty-pt/lemma
import { foldAccents, tokenize, LemmaIndex } from "@tty-pt/lemma";

// 1. Unicode Case Folding (lowercasing while preserving language-specific accents)
const folded = foldAccents("Pão de Évora");
console.log(folded); // "pão de évora"

// 2. Tokenization into normalized word units
const tokens = tokenize("O pão fresco na padaria!");
console.log(tokens); // ["pão", "fresco", "na", "padaria"]

// 3. Fast In-Memory Lexical Indexing & BM25-style Search
const index = new LemmaIndex();
index.addDocument(1, "Padaria tradicional com pão fresco");
index.addDocument(2, "Restaurante de peixe grelhado");
index.addDocument(3, "Café com pão de queijo");

const results = index.search("pão");
console.log(results); // [{ id: 1, score: 1 }, { id: 3, score: 1 }]

2. Invariants & Multilingual Features

  • Accent-Sensitive Preserving: Unlike crude regex lowercasing that destroys diacritics, lemma_fold respects Unicode character properties (Pão $\rightarrow$ pão, Straße $\rightarrow$ straße, ÉTÉ $\rightarrow$ été).
  • Instant Search-as-You-Type: Runs in browser inputs via pre-compiled dist/lemma.wasm with sub-millisecond query execution and zero external runtime dependencies.

3. JavaScript / TypeScript API Reference

foldAccents(text: string): string

Applies Unicode-compliant case folding and diacritic normalization according to language rules. Executes strictly in compiled WebAssembly / C via lemma_fold(), with zero regex heuristic stripping.

tokenize(text: string): string[]

Tokenizes a string into normalized word tokens by folding accents and splitting on non-alphanumeric word boundaries.

LemmaIndex

In-memory lexical search index:

  • .addDocument(id: number | string, text: string): void: Indexes a document's text tokens.
  • .search(query: string): Array<{ id: number | string, score: number }>: Performs token matching and returns documents ranked by overlap score.

LemmaLexicalAxis

Plug-and-play Text Axis adapter for the Corm Recall Kernel (@tty-pt/corm):

  • .registerText(ref: number, text: string): void
  • .fill(params: { term: string }): number[]
  • .rank(params: { term: string }, ref: number): number

getLemmaWasm(): WebAssembly.Instance

Returns the WebAssembly instance loaded on the Stele shared-memory substrate.


4. Dual-Engine Runtime

  • Node.js: Native C99 addon (build/Release/lemma_node.node) linking directly to liblemma.
  • Browser & Edge: Precompiled dist/lemma.wasm reactor with zero native compilation prerequisites.

4. C Development Headers via NPM

CFLAGS += -I./node_modules/@tty-pt/lemma/include
LDLIBS += -llemma

5. Building from Source

make npm-build    # Compiles native addon and WASM reactor
make npm-test     # Runs verification test suite

License

BSD 2-Clause License. Copyright (c) 2026, tty-pt.