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

keychaindb

v2.0.0

Published

A fast key value database

Readme

KeychainDB

KeychainDB is a fast, lightweight, and modular key-value database. Its new v2 architecture is built on a simple core that uses a powerful plugin system, allowing you to add features like persistence, caching, and more without changing the core database logic.

Features

  • Fast Key-Value Storage: Store and retrieve data quickly using simple key-value pairs.
  • Modular & Plugin-based: The core database provides fundamental operations, and all advanced functionality (like persistence) is handled by plugins.
  • Flexible Data Types: Supports any valid JSON data type, including strings, numbers, booleans, arrays, and nested JSON objects.
  • Event-Driven: Listen for events like set, get, and delete to trigger custom logic.

Installation

To install KeychainDB you simply need to use npm.

npm install keychaindb

Usage

Initialization

To start using KeychainDB, initialize the database.

import { Database } from "keychaindb";

const db = new Database();

Setting Values

You can set values for any valid JSON data type.

db.set("user:1", { name: "John", age: 30 });
db.set("product:123", { name: "Laptop", price: 1200 });
db.set("status", true);
db.set("numbers", [10, 20, 30]);
db.set("message", "Hello World");

Getting Values

Retrieve values using the get method.

const user = db.get("user:1");
console.log(user.name); // Output: John

const price = db.get("product:123");
console.log(price); // Output: 1200

Deleting Values

Delete values using the delete method.

db.delete("user:1");

Plugin System

The v2 architecture uses plugins to extend functionality. You use the db.use() method to add a plugin.

import { Database, MyPlugin } from "keychaindb";

const db = new Database();

// Use your custom plugin to add functionality
db.use(new MyPlugin());

Event Handling

You can listen for database events using the on or once methods. All events are now asynchronous.

db.on("set", (key, data) => {
    console.log(`[Event] Key ${key} was set with value: ${data.value}`);
});

db.on("delete", (key) => {
    console.log(`[Event] Key ${key} was deleted`);
});

// To listen for an event only one time
db.once("get", (key, data) => {
    console.log(`[Event] Key ${key} was retrieved for the first time`);
});

To stop listening for events, use db.off().

db.off("set");

Built-in Plugins

KeychainDB offers a simple built-in driver for persistence.

BasePersistencePlugin

This plugin provides basic persistence functionality and serves as a template for more complex drivers.

Usage

To add this plugin, you use the db.use method.

import { Database, BasePersistencePlugin } from "keychaindb";

const db = new Database();
db.use(new BasePersistencePlugin());

This will enable the afterSet and afterDelete hooks, which can be extended to write to disk.

License

KeychainDB is licensed under the ISC License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Author

Made with ❤️ by Alataq

Project owned by Nerexon