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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@allnulled/webmarket

v1.0.0

Published

Wrapper for IndexedDB.

Readme

webmarket

Wrapper for IndexedDB.

Installation

npm install --save @allnulled/webmarket

Then:

<script src="node_modules/@allnulled/webmarket/webmarket.js"></script>

Usage

const wm = await Webmarket.open();
// @TODO: operations

Operations

The window.Wemarket global class has some methods:

  • static create(dbName): creates an instance.
    • Receives String:dbName, the name of the database.
    • Returns Webmarket type.
  • static open(dbName): creates and initializes an instance.
    • Receives String:dbName, the name of the database.
    • Returns Promise<Webmarket> type.
  • static init(dbName)
    • Receives String:dbName, the name of the database.
    • Return Promise<Webmarket> type, and returns wm.init().
  • static listDatabases()
    • Receives nothing.
    • Returns the list of names of databases found.
  • constructor(dbName = "webmarket")
    • Receives String:dbName, the name of the database.
    • Creates the object only. You still need to call to wm.init().
  • async init()
    • Receives nothing. Uses the this.dbName set on the constructor.
    • Ensures the current store and returns an internal IDB object.
  • async changeDatabase(dbName)
    • Receives String:dbName, the name of the database.
    • Changes the name of the database, and calls wm.init() again.
  • async select()
    • Receives nothing. Filters are complicated in IDB.
    • Returns a list of all the items.
  • async selectById(id)
    • Receives Integer:id, the id of the row to select.
    • Returns the item by id, if found.
  • async insertOne(data)
    • Receives Object:item, the item to insert.
    • Inserts one item.
    • Returns the inserted id.
  • async insertMany(items)
    • Receives Array<Object>:items, the items to insert.
    • Inserts a list of items.
    • Returns the inserted ids in a list.
  • async updateOne(id, data)
    • Receives Integer:id, the id of the row to update.
    • Updates one item.
    • Returns the updated id.
  • async deleteOne(id)
    • Receives Integer:id, the id of the row to delete.
    • Deletes one item.
    • Returns nothing.

How it better works?

Just remember this.

Databases are directories. Rows are files indexed by id.

There are no stores with webmarket, no schema versions, no schema modifications.

Only 1 directory and N files. Only 1 database and N registries.

Steps

  1. You open database and store. wm = Webmarket.open(dbName)
  2. You operate the CRUD like so:
    1. all = await wm.select()
    2. one = await wm.selectById(1)
    3. id = await wm.insertOne({})
    4. ids = await wm.insertMany([{}, {}, {}])
    5. id = await wm.updateOne(1, {})
    6. await wm.deleteOne(1)

By default, you work on "webmarket" database, and webstore store.

The idea is to only alter the database name.

Test

// Creamos una instancia de Webmarket
const wm = await Webmarket.open("testDB");

// Insertamos un solo dato
const id = await wm.insertOne({ name: "Item 1", description: "First item" });
console.log(`Inserted item with ID: ${id}`);

// Insertamos varios datos
const ids = await wm.insertMany([
    { name: "Item 2", description: "Second item" },
    { name: "Item 3", description: "Third item" }
]);
console.log(`Inserted items with IDs: ${ids.join(", ")}`);

// Recuperamos todos los elementos
const items = await wm.select();
console.log("All items:", items);

// Actualizamos un elemento
await wm.updateOne(id, { name: "Updated Item 1", description: "Updated description" });
console.log("Updated item with ID:", id);

// Recuperamos el elemento actualizado
const updatedItem = await wm.selectById(id);
console.log("Updated item:", updatedItem);

// Eliminamos un elemento
await wm.deleteOne(id);
console.log("Deleted item with ID:", id);

// Recuperamos todos los elementos después de la eliminación
const remainingItems = await wm.select();
console.log("Remaining items:", remainingItems);