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

nusm

v0.1.0

Published

Non Uniform State Manager nusm (pronounced "noose em") built on @tanstack/store with optional persisted adapters.

Readme

nusm

Non Uniform State Manager (nusm) > Pronounced noose em (/ˈnuːs əm/) is a persistence-ready wrapper around @tanstack/store with adapter-based storage

Features

  • Same store semantics as @tanstack/store
  • Optional persistence via adapters
  • Entire-store or slice-based persistence
  • Async hydration with deep merge
  • Debounced persistence via @tanstack/pacer
  • Adapter events for cross-tab or external updates
  • React hooks (via nusm/react)
  • @tanstack/devtools event support (panel coming soon)

Install

bun install `nusm`

Quick Start

import { createNusmStore, createLocalStorageAdapter } from 'nusm'

const store = createNusmStore(
	{ count: 0 },
	{
		storeId: 'counter',
		adapter: createLocalStorageAdapter(),
		persist: { strategy: 'entire' },
	},
)

await store.ready
store.setState((state) => ({ count: state.count + 1 }))

API

createNusmStore(initialState, options?)

Creates a nusm-backed store.

import { createNusmStore } from 'nusm'

const nusm = createNusmStore(initialState, {
	storeId: 'settings',
	adapter,
	persist: {
		strategy: 'entire',
	},
})

Return value:

  • A @tanstack/store instance extended with ready (resolves when hydration completes).

Persistence strategies

Entire store

persist: { strategy: 'entire' }

Slices

persist: {
	strategy: 'slices',
	slices: [
		{
			key: 'todos',
			select: (state) => state.todos,
			apply: (state, sliceValue) => ({ ...state, todos: sliceValue }),
		},
	],
}

Hydration configuration

persist: {
	strategy: 'entire',
	hydrate: {
		discardPersisted: false,
		validate: (persisted) => ({ ok: true, value: persisted }),
		merge: ({ initial, persisted }) => ({ ...initial, ...persisted }),
	},
}

Adapters

Adapters control persistence. They define how nusm reads/writes state and how external changes (for example, another tab) are observed.

Adapter interface

type NusmAdapter = {
	name: string
	getItem(key: string): unknown | null | Promise<unknown | null>
	setItem(key: string, value: unknown): void | Promise<void>
	removeItem(key: string): void | Promise<void>
	getAllKeys?(): string[] | Promise<string[]>
	clear?(): void | Promise<void>
	subscribe?(listener: (event: { type: 'set' | 'remove' | 'clear'; key?: string }) => void): () => void
	resolveKey?(params: { storeId: string; sliceKey?: string; kind: 'entire' | 'slice' }): string
	pacer?: false | { wait?: number; maxWait?: number; leading?: boolean; trailing?: boolean }
}

Notes:

  • getAllKeys enables more complete persisted snapshots.
  • resolveKey lets you control key layout. When omitted, nusm uses nusm:<storeId>:entire and nusm:<storeId>:slice:<sliceKey>.
  • subscribe should emit adapter events for cross-tab or external updates.
  • pacer controls debouncing of writes. Use false to write immediately.

Creating a custom adapter

const memoryAdapter: NusmAdapter = {
	name: 'memory',
	getItem: (key) => store.get(key) ?? null,
	setItem: (key, value) => store.set(key, value),
	removeItem: (key) => store.delete(key),
	getAllKeys: () => Array.from(store.keys()),
	resolveKey: ({ storeId, kind, sliceKey }) =>
		kind === 'entire'
			? `nusm:${storeId}:entire`
			: `nusm:${storeId}:slice:${sliceKey}`,
}

Local Storage

import { createLocalStorageAdapter } from 'nusm'

const adapter = createLocalStorageAdapter()

Options:

  • storage: a Storage-like implementation (defaults to window.localStorage).
  • prefix: key prefix (default: nusm).
  • serialize: custom serializer (default: superjson.stringify).
  • deserialize: custom deserializer (default: superjson.parse).
  • pacer: persistence debouncer configuration.

Session Storage

import { createSessionStorageAdapter } from 'nusm'

const adapter = createSessionStorageAdapter()

Options:

  • storage: a Storage-like implementation (defaults to window.sessionStorage).
  • prefix: key prefix (default: nusm).
  • serialize: custom serializer (default: superjson.stringify).
  • deserialize: custom deserializer (default: superjson.parse).
  • pacer: persistence debouncer configuration.

IndexDB

import { createIndexDbAdapter } from 'nusm'

const adapter = createIndexDbAdapter({ dbName: 'my-db' })

Options:

  • dbName: database name (default: nusm).
  • storeName: object store name (default: nusm).
  • version: database version (default: 1).
  • serialize: custom serializer (default: superjson.stringify).
  • deserialize: custom deserializer (default: superjson.parse).
  • pacer: persistence debouncer configuration (default: trailing, 100ms).

React Hooks

import { useStore } from 'nusm/react'

useStore uses React 19's useSyncExternalStore and supports selectors and configurable equality checks.

useStore(store, selector?, options?)

Arguments:

  • store: a Nusm store instance returned by createNusmStore.
  • selector (optional): function that receives the full state and returns the selected slice. Defaults to identity (returns full state).
  • options (optional): configuration object with:
    • equal: when true, uses deep equality (fast-equals deepEqual). When false or omitted, uses shallow equality (fast-equals shallowEqual).

Example:

const store = createNusmStore({ user: { name: 'Ada' } })

const name = useStore(store, (state) => state.user.name)
const user = useStore(store, (state) => state.user, { equal: true })

Tests

bun test

Build

bun run build

License

MIT. See LICENSE.