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

@dalibor91/local-store

v2.1.0

Published

Front-end local package

Readme

@dalibor91/local-store

A small browser-oriented library for key–value caching with optional expiration. It offers two backends: LocalStore (Storage API: localStorage or custom) and IndexedDbStorage (IndexedDB), both with the same async API.

What it does

  • LocalStore – Uses the Storage API (localStorage by default, or any object with getItem / setItem / removeItem). Good for smaller data and simple key–value needs.
  • IndexedDbStorage – Uses IndexedDB. Better for larger or structured data and when you need a real database in the browser.

Both support:

  • Prefix – All keys are namespaced under a configurable prefix to avoid clashes.
  • Optional TTLstore(key, value, expirationMs) so entries can expire automatically.
  • Unified APIload, fetch, store, remove with consistent return shapes.

Values are JSON-serialized; expiration is stored with each record and checked on read.

Install

npm install @dalibor91/local-store

Use

LocalStore (localStorage)

import { LocalStore } from "@dalibor91/local-store";

// Default: uses localStorage with prefix "cache"
const store = new LocalStore(localStorage);

// Optional: custom prefix and storage
const custom = new LocalStore(localStorage, { prefix: "my-app" });

// Store a value (optionally with TTL in milliseconds)
await store.store("user", { id: 1, name: "Alice" });
await store.store("token", "abc123", 60 * 60 * 1000); // expires in 1 hour

// Load: returns raw record { exists, expired, value }
const entry = await store.load("user");
if (entry.exists && !entry.expired) {
  console.log(entry.value);
}

// Fetch: returns value or null (and removes if expired)
const token = await store.fetch("token");

// Remove
await store.remove("user");

IndexedDbStorage (IndexedDB)

import { IndexedDbStorage } from "@dalibor91/local-store";

// prefix is used as the IndexedDB database name
const store = new IndexedDbStorage({ prefix: "my-app" });

await store.store("data", { large: "object" });
const entry = await store.load("data");
const value = await store.fetch("data");
await store.remove("data");

API summary

| Method | Returns | Description | | ----------------- | -------------------- | ------------------------------------------------ | | load(key) | Promise<Entry<T>> | { exists, expired, value }; does not remove. | | fetch(key) | Promise<T \| null> | Value if present and not expired; removes if expired. | | store(key, value, expirationMs?) | Promise<Entry<T>> | Writes (and overwrites) a key; optional TTL. | | remove(key) | Promise<void> | Deletes the key. |

Constructor options (both stores):

  • prefix – Key/database namespace (default: "cache").
  • debug – Enable debug logging (default: false).