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

tiny-vector-db

v0.1.0

Published

A lightweight embedding-based search SDK for Node.js.

Downloads

115

Readme

tiny-vector-db

A lightweight vector search SDK for Node.js.

tiny-vector-db stores embeddings locally, performs cosine-similarity search, and keeps embedding integration optional so you can use OpenAI or your own provider.

Install

npm install tiny-vector-db

Features

  • In-memory storage by default
  • JSON file persistence with automatic writes
  • Cosine similarity search
  • Optional OpenAI embedding helper
  • Custom embedder support for any provider
  • Typed TypeScript API

API

class MiniVectorDB {
  constructor(options?: DBOptions);

  add(item: VectorItem): Promise<void>;

  addMany(items: VectorItem[]): Promise<void>;

  search(queryVector: number[], k?: number): Promise<SearchResult[]>;

  searchText(query: string, k?: number): Promise<SearchResult[]>;

  delete(id: string): Promise<void>;

  clear(): Promise<void>;
}

type VectorItem = {
  id: string;
  vector: number[];
  metadata?: Record<string, unknown>;
};

type SearchResult = {
  id: string;
  score: number;
  metadata?: Record<string, unknown>;
};

type DBOptions = {
  storage?: "memory" | "json" | "sqlite";
  path?: string;
  embedder?: (text: string) => Promise<number[]>;
  apiKey?: string;
  embeddingModel?: string;
  baseUrl?: string;
};

Quick Start

In-memory search

import { MiniVectorDB } from "tiny-vector-db";

const db = new MiniVectorDB();

await db.add({
  id: "hello",
  vector: [0.9, 0.1, 0.1],
  metadata: { text: "hello world" },
});

await db.add({
  id: "goodbye",
  vector: [0.1, 0.9, 0.1],
  metadata: { text: "goodbye world" },
});

const results = await db.search([1, 0, 0], 1);
console.log(results);

JSON persistence

import { MiniVectorDB } from "tiny-vector-db";

const db = new MiniVectorDB({
  storage: "json",
  path: "./db.json",
});

await db.add({
  id: "1",
  vector: [0.3, 0.4, 0.5],
  metadata: { text: "hello world" },
});

OpenAI embeddings

import { MiniVectorDB, embed } from "tiny-vector-db";

const db = new MiniVectorDB({
  storage: "json",
  path: "./db.json",
  apiKey: process.env.OPENAI_API_KEY,
});

await db.add({
  id: "1",
  vector: await embed("hello world"),
  metadata: { text: "hello world" },
});

const results = await db.searchText("greeting", 3);
console.log(results);

Custom embedder

import { MiniVectorDB } from "tiny-vector-db";

const fakeEmbedder = async (text: string) => {
  const code = text.length;
  return [code, code / 2, code / 4];
};

const db = new MiniVectorDB({ embedder: fakeEmbedder });

await db.add({
  id: "1",
  vector: await fakeEmbedder("hello world"),
  metadata: { text: "hello world" },
});

const results = await db.searchText("hello", 3);
console.log(results);

Notes

  • JSON storage writes to a temporary file first, then renames it into place.
  • All vectors in a database must have the same dimension.
  • sqlite is reserved in the API but not implemented in this minimal build yet.

Development

npm install
npm run build