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

@students-dev/local-storage-api

v1.0.0

Published

A comprehensive, production-ready client-side storage API with advanced features, automatic fallbacks, and developer tooling

Readme

Local Storage API v1.0.0

Created by Ramkrishna Bhatt V, Milagres PU College, Kallianpur, Udupi

A comprehensive, production-ready client-side storage API with advanced features, automatic fallbacks, and developer tooling. Store any data type including Objects, Arrays, Blobs, Files, Buffers, TypedArrays, JSON, numbers, strings, booleans, Maps, and Sets.

Installation

npm install @students-dev/local-storage-api

Quick Start

const { LocalStorageAPI, useStore } = require('@students-dev/local-storage-api');

const storage = new LocalStorageAPI();

// Simple API
await storage.save('user', { name: 'Alice', age: 25 });
const user = await storage.load('user');
await storage.delete('user');

// Namespaced storage
const appStorage = useStore('myapp');
await appStorage.save('config', { theme: 'dark' });

// Batch operations
await storage.saveMany([
  ['setting1', 'value1'],
  ['setting2', 'value2']
]);
const values = await storage.loadMany(['setting1', 'setting2']);

// Export/Import
const data = await storage.exportJSON();
await storage.importJSON(data);

Features

Core Features

  • Automatic Fallbacks: IndexedDB → LocalStorage → In-memory
  • Any Data Type: Supports all JavaScript data types with auto-serialization
  • TTL Support: Time-to-live for automatic expiration
  • Batch Operations: Efficient bulk operations
  • Namespacing: Isolated storage scopes
  • Event System: Real-time change notifications
  • TypeScript Support: Full type definitions included

Advanced Features

  • Compression: lz-string and MessagePack serialization
  • Storage Profiles: ultra-fast, max-compression, low-memory, safe-mode
  • Snapshots: Save/load/compare storage states
  • Query Engine: SQL-like querying with filter, sort, limit
  • Metrics & Monitoring: Read/write counts, latency tracking
  • Audit Logging: Complete operation history
  • Cross-tab Sync: BroadcastChannel real-time synchronization
  • Encryption Hooks: User-provided crypto integration
  • Migration System: Versioned schema migrations
  • Benchmark API: Performance testing utilities

API Reference

Simple API

// Core operations
await storage.save(key, value, options?)
await storage.load(key) // -> value or null
await storage.delete(key)
await storage.reset() // Clear all

// Utility
await storage.exists(key) // -> boolean
await storage.count() // -> number
await storage.all() // -> { key: value, ... }

// Batch
await storage.saveMany([[key1, value1], [key2, value2]])
await storage.loadMany([key1, key2]) // -> { key1: value1, ... }
await storage.deleteMany([key1, key2])

// Import/Export
await storage.exportJSON() // -> JSON string
await storage.importJSON(jsonString)
await storage.exportFile() // Browser download

Advanced API

// Direct access
await storage.set(key, value, { ttl: 3600 })
await storage.get(key)
await storage.remove(key)
await storage.clear()

// Querying
const results = await storage.query()
  .filter(value => value.price > 100)
  .sort((a, b) => a.price - b.price)
  .limit(10)
  .execute()

// Snapshots
await storage.saveSnapshot('backup')
await storage.loadSnapshot('backup')
const diff = storage.compareSnapshots('snap1', 'snap2')

// Metrics
const metrics = storage.getMetrics()
// { reads: 10, writes: 5, avgReadLatency: 2.3, ... }

// Events
storage.on('change', (event) => {
  console.log('Storage changed:', event);
});

Configuration

const storage = new LocalStorageAPI({
  namespace: 'myapp',
  profile: 'max-compression', // ultra-fast, max-compression, low-memory, safe-mode
  debug: true,
  safeMode: false,
  hooks: {
    beforeSet: (key, value) => {
      // Validate or transform
      return value;
    }
  },
  encryption: {
    preWriteEncrypt: (data) => encrypt(data),
    postReadDecrypt: (data) => decrypt(data)
  },
  sync: {
    channel: new BroadcastChannel('my-app-sync')
  }
});

Browser Support

  • Chrome 24+
  • Firefox 16+
  • Safari 10+
  • Edge 12+

CLI Tool

# Install globally
npm install -g @students-dev/local-storage-api

# Commands
local-storage-api inspect          # Show storage stats
local-storage-api export data.json # Export to file
local-storage-api import data.json # Import from file
local-storage-api visualize        # Data type charts
local-storage-api benchmark        # Performance test

VS Code Extension

Install the "Local Storage API" extension for advanced debugging:

  • Storage Explorer: Tree view of all storage
  • Inspector Panel: Real-time storage inspection
  • Metrics Dashboard: Performance monitoring
  • Snapshot Management: Save/compare/restore states
  • Diff Viewer: Side-by-side snapshot comparison

Examples

See the examples/ directory:

  • examples/plain-js.js - Vanilla JavaScript
  • examples/react.js - React hooks
  • examples/vue.js - Vue composables
  • examples/svelte.js - Svelte stores

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

# Lint
npm run lint

# Format code
npm run format

Architecture

The API implements a layered storage architecture:

  1. IndexedDB Layer: Primary async storage with high capacity
  2. LocalStorage Layer: Sync fallback with browser persistence
  3. Memory Layer: In-memory fallback for basic functionality

Automatic fallback ensures reliability across all environments.

Migration Guide

From v0.x to v1.0.0

The v1.0.0 introduces breaking changes:

  • store() renamed to save()
  • retrieve() renamed to load()
  • New advanced features available
  • Improved error handling
// Old v0.x
await store('key', 'value');
const value = await retrieve('key');

// New v1.0.0
await storage.save('key', 'value');
const value = await storage.load('key');

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Copyright

© 2024 Ramkrishna Bhatt V (Milagres PU College, Kallianpur, Udupi). All rights reserved.