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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@writewhisker/storage

v0.1.0

Published

Framework-agnostic storage layer for Whisker interactive fiction

Readme

@writewhisker/storage

Framework-agnostic storage layer for Whisker interactive fiction.

Features

  • Multiple Backends: IndexedDB, localStorage, and extensible to filesystem, cloud, and database storage
  • Event-Driven: Emits events for all storage operations, enabling reactive UIs
  • Framework Agnostic: Works with any UI framework (Svelte, React, Vue, etc.)
  • Type-Safe: Full TypeScript support with comprehensive type definitions
  • Async/Await: Modern async API for all operations

Installation

pnpm add @writewhisker/storage

Quick Start

import { createIndexedDBStorage, StorageEventType } from '@writewhisker/storage';

// Create storage service with IndexedDB backend
const storage = createIndexedDBStorage();

// Initialize
await storage.initialize();

// Listen to events
storage.on(StorageEventType.STORY_SAVED, (event) => {
  console.log('Story saved:', event.storyId, event.title);
});

// Save a story
await storage.saveStory('story-1', {
  id: 'story-1',
  title: 'My First Story',
  passages: [],
  // ... other story data
});

// Load a story
const story = await storage.loadStory('story-1');

// List all stories
const stories = await storage.listStories();

Backends

IndexedDB (Recommended for browsers)

Best for browser environments. No size limitations (unlike localStorage).

import { IndexedDBBackend, StorageService } from '@writewhisker/storage';

const storage = new StorageService(new IndexedDBBackend());
await storage.initialize();

localStorage (Simple alternative)

Simple but has ~5-10MB size limit.

import { LocalStorageBackend, StorageService } from '@writewhisker/storage';

const storage = new StorageService(new LocalStorageBackend());
await storage.initialize();

Events

The storage service emits events for all operations:

  • STORY_SAVED - When a story is saved
  • STORY_LOADED - When a story is loaded
  • STORY_DELETED - When a story is deleted
  • STORY_CREATED - When a new story is created
  • STORY_UPDATED - When an existing story is updated
  • METADATA_UPDATED - When story metadata is updated
  • STORAGE_CLEARED - When all storage is cleared
  • ERROR - When an error occurs
storage.on(StorageEventType.STORY_SAVED, (event) => {
  console.log('Story saved:', event);
});

storage.on(StorageEventType.ERROR, (event) => {
  console.error('Storage error:', event.error, event.operation);
});

API Reference

StorageService

Methods

  • initialize(): Promise<void> - Initialize the backend
  • saveStory(id: string, data: StoryData, isNew?: boolean): Promise<void> - Save a story
  • loadStory(id: string): Promise<StoryData> - Load a story
  • deleteStory(id: string): Promise<void> - Delete a story
  • listStories(): Promise<StorageMetadata[]> - List all stories
  • hasStory(id: string): Promise<boolean> - Check if story exists
  • getMetadata(id: string): Promise<StorageMetadata> - Get story metadata
  • updateMetadata(id: string, metadata: Partial<StorageMetadata>): Promise<void> - Update metadata
  • exportStory(id: string): Promise<Blob> - Export story as JSON blob
  • importStory(data: Blob | File): Promise<string> - Import story from file
  • getStorageUsage(): Promise<number> - Get storage usage in bytes
  • clear(): Promise<void> - Clear all storage

Custom Backends

Implement the IStorageBackend interface to create custom backends:

import type { IStorageBackend, StorageMetadata } from '@writewhisker/storage';
import type { StoryData } from '@writewhisker/core-ts';

class MyCustomBackend implements IStorageBackend {
  async initialize(): Promise<void> {
    // Initialize your backend
  }

  async saveStory(id: string, data: StoryData): Promise<void> {
    // Save implementation
  }

  // Implement other required methods...
}

const storage = new StorageService(new MyCustomBackend());

License

MIT