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

@trovec/embedder-local

v1.0.0

Published

Zero-dependency local text embedder for Trovec. For prototyping and testing only.

Readme

@trovec/embedder-local

A zero-dependency local text embedder for Trovec. Converts text to vector embeddings using character n-gram hashing — no API keys, no model files, no setup required.

Warning: This embedder uses simple text hashing, not a real ML model. It does not capture true semantic meaning. Use it for prototyping, testing, CI, and demos only. For production, use a proper embedding model like @trovec/embedder-openai.

Installation

npm install @trovec/core @trovec/embedder-local

Usage

import { create, addWithText, queryByText } from '@trovec/core';
import { createLocalEmbedder } from '@trovec/embedder-local';

const db = create({
  dimensions: 64,
  embedder: createLocalEmbedder(),
});

await addWithText(db, { id: 'doc1', text: 'Cats are curious animals' });
await addWithText(db, { id: 'doc2', text: 'Dogs love to play fetch' });
await addWithText(db, { id: 'doc3', text: 'TypeScript adds static typing' });

const results = await queryByText(db, { text: 'pets and animals', topK: 2 });
// Returns doc1 and doc2 (animal-related documents rank higher)

Options

createLocalEmbedder({
  dimensions?: number;  // default: 64
  warn?: boolean;       // default: true — prints a one-time warning to stderr
})

Suppressing the Warning

The embedder prints a one-time warning on first use to remind you it's not for production. To suppress it:

createLocalEmbedder({ warn: false })

How It Works

  1. Tokenizes input text by whitespace
  2. Extracts character bigrams and trigrams from each token
  3. Hashes each n-gram to a dimension index using a multiply-and-xor hash
  4. Accumulates weighted values into a fixed-size vector
  5. L2-normalizes the result to unit length

This produces deterministic, reproducible embeddings that capture surface-level text similarity (shared character sequences) rather than deep semantic meaning.

When to Use This vs a Real Embedder

| Use case | Recommended embedder | |----------|---------------------| | Learning the Trovec API | @trovec/embedder-local | | Unit tests / CI | @trovec/embedder-local | | Demos and prototypes | @trovec/embedder-local | | Production search | @trovec/embedder-openai or similar | | Semantic similarity | @trovec/embedder-openai or similar |

License

MIT