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

@resourcexjs/storage

v2.5.5

Published

ResourceX Storage - Low-level storage backends

Downloads

1,108

Readme

@resourcexjs/storage

Low-level key-value storage backends for ResourceX.

Installation

bun add @resourcexjs/storage

Overview

This package provides a pure key-value storage abstraction layer. It deals only with raw bytes (Buffer), leaving higher-level object handling to the Registry layer.

Storage Interface

All storage implementations conform to this interface:

interface Storage {
  get(key: string): Promise<Buffer>;
  put(key: string, data: Buffer): Promise<void>;
  delete(key: string): Promise<void>;
  exists(key: string): Promise<boolean>;
  list(prefix?: string): Promise<string[]>;
}

Implementations

FileSystemStorage

Local filesystem storage. Keys are treated as relative paths within a base directory.

import { FileSystemStorage } from "@resourcexjs/storage";

const storage = new FileSystemStorage("/path/to/storage");

// Store data
await storage.put("resources/hello/manifest.json", Buffer.from('{"name":"hello"}'));

// Retrieve data
const data = await storage.get("resources/hello/manifest.json");

// Check existence
const exists = await storage.exists("resources/hello/manifest.json");

// List keys with prefix
const keys = await storage.list("resources/hello");
// → ["resources/hello/manifest.json", "resources/hello/archive.tar.gz"]

// Delete (supports recursive directory deletion)
await storage.delete("resources/hello");

Features:

  • Automatic parent directory creation on put()
  • Recursive directory deletion on delete()
  • Recursive file listing with list()

MemoryStorage

In-memory storage for testing and ephemeral use cases.

import { MemoryStorage } from "@resourcexjs/storage";

const storage = new MemoryStorage();

await storage.put("key", Buffer.from("value"));
const data = await storage.get("key");

// Test utilities
storage.size(); // Get number of stored keys
storage.clear(); // Clear all data

Error Handling

All storage errors throw StorageError with a specific error code:

import { StorageError } from "@resourcexjs/storage";

try {
  await storage.get("nonexistent");
} catch (error) {
  if (error instanceof StorageError) {
    console.log(error.code); // "NOT_FOUND" | "READ_ERROR" | "WRITE_ERROR" | "DELETE_ERROR"
    console.log(error.message);
  }
}

API Reference

FileSystemStorage

constructor(basePath: string)

Creates a storage instance backed by the local filesystem.

| Method | Description | | ---------------- | -------------------------------------------------------------------------------- | | get(key) | Read file contents. Throws StorageError with code NOT_FOUND or READ_ERROR. | | put(key, data) | Write data. Creates parent directories automatically. | | delete(key) | Delete file or directory recursively. | | exists(key) | Check if file exists. | | list(prefix?) | List all files under prefix recursively. |

MemoryStorage

constructor();

Creates an in-memory storage instance.

| Method | Description | | ---------------- | -------------------------------------------------------------- | | get(key) | Get stored value. Throws StorageError with code NOT_FOUND. | | put(key, data) | Store value. | | delete(key) | Delete key and all keys with matching prefix. | | exists(key) | Check if key exists. | | list(prefix?) | List all keys matching prefix. | | clear() | Clear all stored data. | | size() | Get number of stored keys. |

StorageError

class StorageError extends Error {
  code: "NOT_FOUND" | "WRITE_ERROR" | "READ_ERROR" | "DELETE_ERROR";
}

Planned Implementations

  • S3Storage - AWS S3
  • R2Storage - Cloudflare R2

License

Apache-2.0