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

storage-box

v1.0.4

Published

A memory-based key–value storage for javascript.

Readme

storage-box is a versatile JavaScript key–value storage library supporting memory, file system, and browser drivers with expiration and rich data structures.


📦 Installation

npm install storage-box

pnpm

pnpm install storage-box

yarn

yarn add storage-box

📖 Usage

Basic Usage

import { Client } from 'storage-box';

const client = new Client();

client.set('key', 'value');
console.log(client.get('key')); // 'value'

Storage Drivers

Memory (Default)

In-memory storage driver requiring zero setup.

import { Client, MemoryDriver } from 'storage-box';

const client = new Client(new MemoryDriver());

File-based Storage (fs)

File system driver supporting Node.js and Bun environments with JSON or MessagePack serialization.

import path from 'node:path';
import { FsDriver, MSGPack } from 'storage-box/node';
import { Client } from 'storage-box';

// JSON file storage (default)
const jsonDriver = new FsDriver(path.resolve('data.json'));
const client = new Client(jsonDriver);

// MessagePack binary storage
const msgpackDriver = new FsDriver(path.resolve('data.b64'), {
  parser: MSGPack,
});
const mpClient = new Client(msgpackDriver);

Browser Storage

Local or Session storage driver for web applications.

import { Client } from 'storage-box';
import { BrowserDriver } from 'storage-box/browser';

const driver = new BrowserDriver('local'); // or 'session'
const client = new Client(driver);

client.set('theme', 'dark');

Automatic Key Expiration (TTL)

Set keys with expiration time in seconds and inspect remaining TTL.

import { Client } from 'storage-box';

const client = new Client();

client.setex('session', 'secret-token', 10); // expires in 10 seconds

console.log(client.ttl('session')); // remaining time in seconds
console.log(client.ttl('session', true)); // remaining time in milliseconds

Hash Operations

Store key-value pairs inside nested hash structures.

import { Client } from 'storage-box';

const client = new Client();

client.hset('user:100', 'name', 'John');
client.hset('user:100', 'email', '[email protected]');

console.log(client.hget('user:100', 'name')); // 'John'
console.log(client.hgetall('user:100')); // { name: 'John', email: '[email protected]' }

List Operations

Work with ordered arrays and push/pop elements.

import { Client } from 'storage-box';

const client = new Client();

client.lpush('tasks', 'write docs');
client.lpush('tasks', 'publish package');

console.log(client.lpop('tasks')); // 'publish package'
console.log(client.lrange('tasks', 0, -1)); // ['write docs']

Custom HashMap & List Classes

Extend HashMap or List for custom data structures and domain logic.

import { Client, HashMap } from 'storage-box';

interface User {
  first: string;
  last: string;
}

class UserMap extends HashMap<string, User> {
  async getInitials(): Promise<string[]> {
    const all = await this.getall();
    return Object.values(all).map((u) => `${u.first[0]}${u.last[0]}`);
  }
}

const users = client.createHashMap('users', UserMap);
await users.set('u1', { first: 'John', last: 'Doe' });

📚 Documentation

For all configuration options, please see the API docs.

🤝 Contributing

Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.

Thanks again for your support, it is much appreciated! 🙏

License

MIT © Shahrad Elahi and contributors.