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

@grimoire-intel/clavicula-extras

v1.0.1

Published

Optional decorators for [Clavicula](https://github.com/grimoire-intelligence/clavicula) stores.

Readme

@grimoire-intel/clavicula-extras

Optional decorators for Clavicula stores.

Installation

npm install @grimoire-intel/clavicula @grimoire-intel/clavicula-extras

Decorators

withPersist

Syncs store state with localStorage.

import { createStore } from '@grimoire-intel/clavicula';
import { withPersist, withBatching } from '@grimoire-intel/clavicula-extras';

// Always wrap with withBatching to avoid excessive writes
const settings = withPersist(
  withBatching(createStore({ theme: 'light' })),
  'app-settings'
);

withBatching

Batches multiple synchronous updates into a single notification. Includes built-in equality checking.

import { withBatching } from '@grimoire-intel/clavicula-extras';

const store = withBatching(createStore({ x: 0, y: 0 }));

// These three calls result in one notification
store.set({ x: 1 });
store.set({ y: 2 });
store.set({ x: 10 });
// Subscribers see: { x: 10, y: 2 }

Note: React, Vue, Solid, and Angular batch renders internally, so withBatching provides less visible benefit for rendering. However, it's still valuable for:

  • Reducing notification overhead (N calls → 1 notification)
  • Filtering no-op updates via equality checking
  • Protecting withPersist from excessive localStorage writes

Most useful for vanilla JS, Svelte, and when composing with withPersist.

withHistory

Adds undo/redo capability.

import { withHistory } from '@grimoire-intel/clavicula-extras';

const store = withHistory(createStore({ text: '' }));

store.set({ text: 'hello' });
store.set({ text: 'hello world' });

store.undo(); // { text: 'hello' }
store.redo(); // { text: 'hello world' }

store.canUndo(); // true
store.canRedo(); // false

withReset

Adds a reset method to restore initial state.

import { withReset } from '@grimoire-intel/clavicula-extras';

const store = withReset(createStore({ count: 0 }));

store.set({ count: 99 });
store.reset(); // { count: 0 }

withFreeze

Deep freezes state after every update to catch accidental mutations. No-op in production.

import { withFreeze } from '@grimoire-intel/clavicula-extras';

const store = withFreeze(createStore({ items: [] }));

store.get().items.push('oops'); // Throws in development

withLogging

Logs state changes to console.

import { withLogging } from '@grimoire-intel/clavicula-extras';

const store = withLogging(createStore({ count: 0 }), 'counter');
// Logs: [counter] { count: 0 }

store.set({ count: 1 });
// Logs: [counter] { count: 1 }

Composition Order

Decorators that use subscribe() internally must be outermost:

// Correct order
withPersist(
  withBatching(
    withHistory(
      withFreeze(store)
    )
  ),
  'key'
)

See Writing Decorators for details.

API

function withPersist<T>(store: Store<T>, key: string): Store<T>;
function withBatching<T>(store: Store<T>, isEqual?: (a: T, b: T) => boolean): Store<T>;
function withHistory<T>(store: Store<T>, maxSize?: number): HistoryStore<T>;
function withReset<T>(store: Store<T>): Store<T> & { reset(): void };
function withFreeze<T>(store: Store<T>): Store<T>;
function withLogging<T>(store: Store<T>, label?: string): Store<T>;

See the main documentation for full API reference.