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

@dephub/cache

v3.0.0

Published

Tiny, type-safe cache with in-memory, file, and browser persistence backends.

Readme

@dephub/cache 💾

Tiny, type-safe cache with in-memory, file, and browser persistence backends.

NPM version ESM-only

Features ✨

  • 🧠 In-memory (Memory) – fast, synchronous, lightweight
  • 💽 File-backed (Disk) – persistent JSON cache with lazy loading
  • 🌐 Browser localStorage (Storage) – automatic persistence in the browser
  • Type-safe – only string | number | boolean values
  • 🚨 Consistent errorsError for all failures

Installation 💿

# Using npm
npm install @dephub/cache

# Using pnpm
pnpm add @dephub/cache

# Using yarn
yarn add @dephub/cache

Usage 🎉

CLI

# Set a value (automatically detects type)
cache set username "john_doe"
cache set score 100
cache set active true

# Get a value
cache get username

# List all entries
cache list

# Delete an entry
cache delete username

# Clear all cache
cache clear

API 🧩

Memory – In-memory cache

import { Memory } from '@dephub/cache';

const cache = new Memory();
cache.set('theme', 'dark');
cache.set('count', 42);
cache.set('active', true);

console.log(cache.get('theme')); // => "dark"
console.log(cache.size()); // => 3

Disk – File-based persistent cache

import { Disk } from '@dephub/cache';

const cache = new Disk('config/app.json');

await cache.set('user', 'alice');
console.log(await cache.get('user')); // => "alice"

// File `config/app.json` now contains:
// {
//   "user": "alice"
// }

Storage – Browser localStorage cache

import { Storage } from '@dephub/cache';

const cache = new Storage('my-app');
cache.set('lang', 'es');
console.log(cache.get('lang')); // => "es"

// Persisted in localStorage under key "my-app"

Error handling

import { Error } from '@dephub/cache';

try {
  cache.set(123, 'invalid'); // throws
} catch (err) {
  if (err instanceof Error) {
    console.error(err.message); // "Cache key must be a string"
  }
}

Shared interface

All backends share the same API:

await cache.set('key', value);
await cache.get('key');
await cache.has('key');
await cache.delete('key');
await cache.clear();
await cache.size();
await cache.keys();
await cache.values();
await cache.entries();
await cache.forEach((value, key) => { ... });

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R (estarlincito.com)