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

babbage-kvstore

v2.0.1

Published

Blockchain-based key-value storage for local and global use

Readme

babbage-kvstore

Blockchain-based key-value storage for local and global use

API

Links: API, Classes

Classes

Class: localKVStore

Implements a key-value storage system backed by transaction outputs managed by a wallet. Each key-value pair is represented by a PushDrop token output in a specific context (basket). Allows setting, getting, and removing key-value pairs, with optional encryption.

export default class localKVStore {
    constructor(wallet: WalletInterface = new WalletClient(), context = "kvstore-default", encrypt = true) 
    async get(key: string, defaultValue: string | undefined = undefined): Promise<string | undefined> 
    async set(key: string, value: string): Promise<OutpointString> 
    async remove(key: string): Promise<OutpointString | void> 
}
Constructor

Creates an instance of the localKVStore.

constructor(wallet: WalletInterface = new WalletClient(), context = "kvstore-default", encrypt = true) 

Argument Details

  • wallet
    • The wallet interface to use. Defaults to a new WalletClient instance.
  • context
    • The context (basket) for namespacing keys. Defaults to 'kvstore-default'.
  • encrypt
    • Whether to encrypt values. Defaults to true.

Throws

If the context is missing or empty.

Method get

Retrieves the value associated with a given key.

async get(key: string, defaultValue: string | undefined = undefined): Promise<string | undefined> 

Returns

A promise that resolves to the value as a string, the defaultValue if the key is not found, or undefined if no defaultValue is provided.

Argument Details

  • key
    • The key to retrieve the value for.
  • defaultValue
    • The value to return if the key is not found.

Throws

If multiple outputs are found for the key (ambiguous state).

If the found output's locking script cannot be decoded or represents an invalid token format.

Method remove

Removes the key-value pair associated with the given key. It finds the existing output(s) for the key and spends them without creating a new output. If multiple outputs exist, they are all spent in the same transaction. If the key does not exist, it does nothing. If signing the removal transaction fails, it relinquishes the original outputs instead of spending.

async remove(key: string): Promise<OutpointString | void> 

Returns

A promise that resolves to the txid of the removal transaction if successful.

Argument Details

  • key
    • The key to remove.
Method set

Sets or updates the value associated with a given key. If the key already exists (one or more outputs found), it spends the existing output(s) and creates a new one with the updated value. If multiple outputs exist for the key, they are collapsed into a single new output. If the key does not exist, it creates a new output. Handles encryption if enabled. If signing the update/collapse transaction fails, it relinquishes the original outputs and starts over with a new chain.

async set(key: string, value: string): Promise<OutpointString> 

Returns

A promise that resolves to the outpoint string (txid.vout) of the new or updated token output.

Argument Details

  • key
    • The key to set or update.
  • value
    • The value to associate with the key.

Links: API, Classes


License

The license for the code in this repository is the Open BSV License.