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

super-indexdb

v1.0.0

Published

A minimal, auto-migrating wrapper for idb.

Readme

I will assume the README is for your IndexedDB Starter Project which includes the Table class with the findByRange functionality you were working on.

Here is a simple, concise, and complete README for that project.


🚀 IndexedDB Starter Project

This project provides a clean, class-based wrapper for working with the browser's native IndexedDB database, focusing on simple CRUD (Create, Read, Update, Delete) and advanced range queries.


🎯 How It Works

This project simplifies IndexedDB by using the Table class to manage a single Object Store (similar to a SQL table).

  1. Initialization: The Database class is a singleton that connects to IndexedDB, creates necessary Object Stores, and sets up any required Indexes.
  2. Interaction: The Table class uses a modern, Promise-based API to wrap raw IndexedDB requests, eliminating the need to handle low-level event listeners.
  3. Range Queries: The findByRange method allows you to query data using flexible boundary options (gte, gt, lte, lt), which are translated directly into native IDBKeyRange objects.

🛠️ How to Use It

1. Installation

Assuming you have Node.js and a package manager:

npm install # or yarn install / pnpm install

2. Initialization & Setup

First, you instantiate the database. This typically happens once in your application's entry point.

import { Database } from './src/database'; // Adjust path as needed

// 1. Define your database name and Object Store names
const DB_NAME = 'MySpacedRepDb';
const STORE_NAME = 'cards';

// 2. Instantiate the database
const db = new Database(DB_NAME, 1, (db, oldVersion) => {
    // This is the migration/upgrade function
    if (oldVersion < 1) {
        const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
        // Example: Create an index for querying by 'deckId'
        store.createIndex('deckId', 'deckId', { unique: false });
    }
});

// 3. Get a reference to your table
const cardsTable = db.getTable(STORE_NAME);

3. Basic CRUD Operations

The cardsTable object now provides simple methods:

| Action | Method | Example | | :--- | :--- | :--- | | Create | add(value) | await cardsTable.add({ id: 1, front: 'Hello' }); | | Read | get(key) | const card = await cardsTable.get(1); | | Update | put(value) | await cardsTable.put({ id: 1, front: 'Hi there' }); | | Delete | delete(key) | await cardsTable.delete(1); |

4. Advanced Range Query

Use the findByRange method to fetch items based on an Index and a Range Configuration.

The range object accepts any combination of boundary keys:

| Key | Description | | :--- | :--- | | gte | Greater Than or Equal to (inclusive lower bound) | | gt | Greater Than (exclusive lower bound) | | lte | Less Than or Equal to (inclusive upper bound) | | lt | Less Than (exclusive upper bound) |

Example: Find cards where deckId is between 5 and 10 (inclusive)

const rangeQuery = {
    gte: 5, // Deck IDs greater than or equal to 5
    lte: 10 // Deck IDs less than or equal to 10
};

const cards = await cardsTable.findByRange('deckId', rangeQuery);
// cards will contain all items where card.deckId >= 5 AND card.deckId <= 10

Ready to start adding some data and running your own queries?