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

browser-kvs

v1.0.0

Published

The key-value store library that allows consistent use of various stores supported by modern browsers.

Readme

Browser KVS

Hits NPM Version NPM Downloads

codecov

Browser KVS is a versatile key-value store library designed to provide consistent usage across various storage options supported by modern browsers, such as localStorage and sessionStorage.

Features

  • Unified API: Access different browser storage mechanisms through a single interface.
  • Lightweight Dependency: Uses is-number to validate numeric inputs.
  • TypeScript Support: Includes type definitions for seamless integration in TypeScript projects.
  • Various integration methods Support
    • Both ESM(ECMAScript Modules) and CJS(CommonJS): Example
    • IIFE(Immediately Invoked Function Expression): Example

Installation

npm install browser-kvs

Examples

typescript

How to access localStorage based key value store using BrowserKvs

import {createLocalStorageStore} from "browser-kvs";

const store = createLocalStorageStore<number>();

const saved: boolean = store.save("myKey", 3.14);
console.log(saved); // true

const loaded: number|undefined = store.load("myKey");
console.log(loaded); // 3.14

const removed: number|undefined = store.remove("myKey");
console.log(removed); // 3.14

const reloaded: number|undefined = store.load("myKey");
console.log(reloaded); // undefined

store.clear();
With callbacks
import {createLocalStorageStore} from "browser-kvs";

const store = createLocalStorageStore<number>({
  onSaved: (success) => console.log("Default:onSaved", success),
  onLoaded: (value) => console.log("Default:onLoaded", value),
  onRemoved: (value) => console.log("Default:onRemoved", value),
  onCleared: () => console.log("Default:onCleared"),
});

const saved: boolean = store.save("myKey1", 3.14); // "Default:onSaved" true
console.log(saved); // true

const notSaved: boolean = store.save("myKey2", 3/0, (success) => console.log("onSaved", success)); // "onSaved" false
console.log(notSaved); // false

const loaded: number|undefined = store.load("myKey1", (value) => console.log("onLoaded", value)); // "onLoaded" 3.14
console.log(loaded); // 3.14

const removed: number|undefined = store.remove("myKey1"); // "Default:onRemoved" 3.14
console.log(removed); // 3.14

const reloaded: number|undefined = store.load("myKey1"); // "Default:onLoaded" undefined
console.log(reloaded); // undefined

store.clear(); // "Default:onCleared"

How to access sessionStorage based key value store using BrowserKvs

Just change the createLocalStorageStore function to the createSessionStorageStore function. The rest is exactly the same as above.

import {createSessionStorageStore} from "browser-kvs";

const store = createSessionStorageStore<number>(/* omitted */);
// The rest is the same as the example of localStorage.

How to access in-memory based key value store using BrowserKvs

Use the createInMemoryStore function to create in-memory based key value store.

import {createInMemoryStore} from "browser-kvs";

const store = createInMemoryStore<number>(/* omitted */);
// The rest is the same as the example of localStorage.

javascript

How to use by ESM(ECMAScript Modules) or CJS(CommonJS)

How to use by IIFE(Immediately Invoked Function Expression)

APIs

createInMemoryStore(defaultCallbacks?: object): Store

  • Create in-memory based key value store

createLocalStorageStore(defaultCallbacks?: object): Store

  • Create localStorage based key value store

createSessionStorageStore(defaultCallbacks?: object): Store

  • Create sesssionStorage based key value store

Store.save(key: string, value: T, callback?: (success: boolean) => void): boolean

  • Save a value with key.
  • Optionally accepts a callback function.

Store.load(key: string, callback?: (value: T | undefined) => void): T|undefined

  • Retrieve a value by key.
  • Optionally accepts a callback function.

Store.remove(key: string, callback?: (value: T | undefined) => void): T|undefined

  • Remove a value by key.
  • Optionally accepts a callback function.

Store.clear(callback?: () => void): void

  • Remove all values.
  • Optionally accepts a callback function.