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-idb-store

v0.1.2

Published

Typed IndexedDB object-store wrapper with promise-based CRUD, bulk, cursor, range, and update helpers.

Readme

tiny-idb-store

IndexedDB object-store wrapper with promise-based CRUD, bulk, cursor, range, and update helpers.

Install

npm install tiny-idb-store

Scripts

  • npm run test — run the Vitest suite with fake IndexedDB
  • npm run build — emit ESM JavaScript and TypeScript declarations to dist
  • npm run lint — run Biome and Oxlint
  • npm run lint:fix — auto-format with Biome
  • npm run check — lint, test, and build

Usage

import { BaseStore } from "tiny-idb-store";

interface Note {
  id?: number;
  title: string;
}

class NotesStore extends BaseStore {
  constructor(db: IDBDatabase) {
    super(db, "notes");
  }
}

class StorageService {
  private static instance: StorageService | null = null;

  private db: IDBDatabase | null = null;
  private notesStore: NotesStore | null = null;
  private readonly name = "notes-db";
  private readonly version = 1;

  private constructor() {}

  get notes(): NotesStore {
    if (!this.notesStore) {
      throw new Error("StorageService is not initialized.");
    }

    return this.notesStore;
  }

  static async create(): Promise<StorageService> {
    if (StorageService.instance) {
      return StorageService.instance;
    }

    const instance = new StorageService();
    await instance.initialize();
    StorageService.instance = instance;

    return instance;
  }

  private async initialize(): Promise<void> {
    this.db = await this.openConnection();
    this.notesStore = new NotesStore(this.db);
  }

  private openConnection(): Promise<IDBDatabase> {
    return new Promise<IDBDatabase>((resolve, reject) => {
      const connection = indexedDB.open(this.name, this.version);

      connection.addEventListener("upgradeneeded", (event: IDBVersionChangeEvent) => {
        const request = event.target as IDBOpenDBRequest;
        const db = request.result;
        const transaction = request.transaction;

        if (!transaction) {
          reject(new Error("Missing upgrade transaction."));
          return;
        }

        switch (event.oldVersion) {
          case 0:
            db.createObjectStore("notes", { keyPath: "id", autoIncrement: true });
            break;
          default:
            break;
        }
      });

      connection.addEventListener(
        "success",
        () => {
          const db = connection.result;
          resolve(db);

          db.addEventListener("close", () => {
            alert("Database connection closed. Please reload the page.");
          });
          db.addEventListener("versionchange", () => {
            db.close();
            alert("Database is outdated. Please reload the page.");
          });
        },
        { once: true },
      );

      connection.addEventListener("error", () => reject(connection.error), { once: true });
      connection.addEventListener(
        "blocked",
        () => {
          alert(
            "Database is outdated. The newer version can't be loaded until you close other tabs. Please reload the page.",
          );
        },
        { once: true },
      );
    });
  }
}

const storage = await StorageService.create();
const noteId = await storage.notes.add({ title: "My first note" });
const note = await storage.notes.get(noteId);
console.log(note);

API

Extend BaseStore with your object store name, then call the promise-based helpers on the subclass instance.

| Method | Description | | --- | --- | | add, bulkAdd | Insert new records | | put, bulkPut | Replace or upsert full records | | get, getAll, count | Read records | | getAllFrom, getAllTo, getAllFromTo | Read by key range | | delete, bulkDelete, clear | Remove records | | update | Patch an existing record by key | | updateByPath | Set a nested field on one record | | updateAll | Patch every record in the store | | updateAllByPath | Set a nested field on every record | | mapAll, findAllBy, takeByLimit, reduce, sliceBy | Cursor-based iteration |

put expects a full record and upserts by key. update reads the current record, merges a partial patch, and returns false when the key is missing.

License

MIT