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

@statewalker/indexer-mem

v0.5.0

Published

In-memory sub-indexes: the block store and full-text base behind the FlexSearch and MiniSearch indexes, and the vector sub-index (MemVectorIndex, brute-force cosine, Arrow persistence) with its VectorProvider.

Downloads

1,758

Readme

@statewalker/indexer-mem

What it is

An in-memory vector sub-index, MemVectorIndex, and memVectorProvider, the VectorProvider that creates it. Search is a brute-force cosine scan over all stored embeddings. The index can save itself as one Apache Arrow IPC stream.

It also holds the in-memory block store behind the full-text indexes. MemBlockStore owns the blocks keyed by path + blockId, path-prefix selection, enumeration, multi-query score fusion (scores summed across queries), dirty tracking and the persistence framing ({ version: 3, ...engineState, blocks }). MemFullTextIndex is the FullTextIndex over that store. A full-text engine plugs in as a MemBlockEngine adapter that supplies only add, remove, search and exportState.

Why it exists

The in-memory indexers (@statewalker/indexer-mem-flexsearch, @statewalker/indexer-mem-minisearch) differ only in their full-text engine. Both use this package for the vector side and for the full-text block store, so the vector code, the block and path rules and the file formats exist once, and another engine costs only an adapter.

How to use

pnpm add @statewalker/indexer-mem

One entry point, @statewalker/indexer-mem: MemVectorIndex, memVectorProvider, MemBlockStore, MemBlockEngine, MemFullTextIndex. Runs anywhere (browser, Node, workers).

Most applications use createFlexSearchIndexer or createMiniSearchIndexer, which already include memVectorProvider. Use this package directly when you build your own indexer from providers.

Examples

Combine with a full-text provider in a custom indexer:

import { createPersistenceBackedIndexer } from "@statewalker/indexer-core";
import { memVectorProvider } from "@statewalker/indexer-mem";
import { flexSearchFullTextProvider } from "@statewalker/indexer-mem-flexsearch";

const indexer = createPersistenceBackedIndexer({
  providers: [flexSearchFullTextProvider, memVectorProvider],
});

Use a MemVectorIndex on its own:

import { MemVectorIndex } from "@statewalker/indexer-mem";

const vectors = new MemVectorIndex({ dimensionality: 3, model: "test" });
await vectors.addDocument([{ path: "/a", blockId: "1", embedding: new Float32Array([1, 0, 0]) }]);
for await (const hit of vectors.search({ embeddings: [new Float32Array([1, 0, 0])], topK: 5 })) {
  console.log(hit.path, hit.blockId, hit.score); // cosine similarity
}

Internals

  • Brute force, on purpose. Every search computes cosine similarity against every stored vector. There is no ANN index, so cost grows linearly with the number of blocks. For large collections use @statewalker/indexer-duckdb or @statewalker/indexer-pglite (HNSW).
  • Persistence. serialise() yields one entry named arrow: an Arrow IPC stream with columns path, blockId, embedding (FixedSizeList<Float32>[dimensionality]) and metadata (JSON text). The bytes are cached until the next change, so repeated flush() calls without writes do not re-encode. loadFrom ignores entries with other names.
  • Several query embeddings: each block keeps its best similarity across them.
  • Dimensionality is checked on addDocument and search: Expected dimensionality 384, got 768.
  • Dependencies: @uwdata/flechette (Arrow encoding without the full Apache Arrow library), @statewalker/indexer-api, @statewalker/indexer-vector, @statewalker/indexer-core.

License

MIT