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

@eserstack/cache

v5.1.0

Published

Readme

📦 @eserstack/cache

Note: JSR is frozen at 4.5.x. From 5.0.0, @eserstack/cache is published on npm under the same name (pnpm add @eserstack/cache); the JSR versions stay available but get no updates.

eserstack Library — eser/stack on GitHub Install: pnpm add @eserstack/cache

Cross-platform cache management with XDG-compliant directory structure.

Features

  • XDG Compliance: Follows XDG Base Directory Specification on Linux
  • Cross-Platform: Platform-specific paths for macOS and Windows
  • Versioned Caching: Built-in support for version-based cache isolation
  • Simple API: Create, check, list, and clear cached items

Quick Start

import * as cache from "@eserstack/cache";

// Create a cache manager for your application
const manager = cache.createCacheManager({
  app: { name: "my-cli", org: "eser" },
});

// Get versioned cache path
const binaryPath = manager.getVersionedPath("1.0.0", "binary");
// Linux: ~/.cache/eser/my-cli/v1.0.0/binary
// macOS: ~/Library/Caches/eser/my-cli/v1.0.0/binary
// Windows: %LOCALAPPDATA%/eser/my-cli/v1.0.0/binary

// Check if cached item exists
if (await manager.exists(binaryPath)) {
  console.log("Using cached binary");
} else {
  await manager.ensureDir(manager.getCacheDir());
  // Download and cache...
}

// List cached items
const entries = await manager.list();

// Clear cache
await manager.clear();

XDG Directory Access

import * as cache from "@eserstack/cache";

const cacheHome = cache.getXdgCacheHome(); // ~/.cache or ~/Library/Caches
const dataHome = cache.getXdgDataHome(); // ~/.local/share or ~/Library/Application Support
const configHome = cache.getXdgConfigHome(); // ~/.config or ~/Library/Preferences

API Reference

createCacheManager(options)

Creates a cache manager instance.

  • options.app.name - Application name
  • options.app.org - Organization name (optional)
  • options.baseDir - Custom base directory (optional)

CacheManager Methods

| Method | Description | | --------------------------------- | ------------------------------------ | | getCacheDir() | Get the base cache directory path | | getVersionedPath(version, name) | Get a versioned cache path | | exists(path) | Check if a path exists | | ensureDir(path) | Create directory if it doesn't exist | | list() | List all cache entries | | remove(path) | Remove a cached item | | clear() | Clear the entire cache |

Every method and the XDG functions run in Go through the @eserstack/ajan bridge (the native library, or its WASM build). The synchronous ones load the bridge on first use, and its WASM build compiles on the calling thread. When neither loads, they throw, and the async methods reject, with the bridge's load error. exists(), ensureDir() and remove() take a path relative to the cache directory or an absolute path.


🔗 For further details, visit the eserstack repository.