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

@j13b/state

v0.1.1

Published

Reactive state primitives — Signals, Runners, Broadcasts — with optional React bindings.

Readme

@j13b/state

Reactive state primitives for TypeScript — Signals, Runners, and broadcast subscriptions, with optional React bindings.

Install

npm install @j13b/state

React is an optional peer dependency — only required if you import from @j13b/state/react.

Quick start

import { Signal } from "@j13b/state";

const counter = new Signal(0);

const subscription = counter.subscribe((value) => {
  console.log("counter is now", value);
});

counter.set(1); // logs: counter is now 1
counter.set(2); // logs: counter is now 2

subscription.unsubscribe();

Entry points

The package ships three entry points so you can pull in only what you need:

| Import path | Use when | |---|---| | @j13b/state | You want everything (signals, runners, React hooks). | | @j13b/state/core | You want the framework-agnostic primitives — no React. | | @j13b/state/react | You want the React-specific hooks and bindings. |

// Framework-agnostic (Node, workers, vanilla TS)
import { Signal, Runner } from "@j13b/state/core";

// React app
import { useSignalValue, useRunnerStatus } from "@j13b/state/react";

What's in the box

  • Signal<T> — reactive value with weakly-held subscriptions, set / transform / wait / waitFor.
  • DerivedSignal — values computed from one or more upstream signals.
  • Runner — async-task lifecycle abstraction with status broadcasting.
  • Broadcast / Subscription — the underlying interfaces that signals and runners implement.
  • EventsEvent, AsyncEvent, BaseEvent for fire-and-forget messaging.
  • HelperspollAsync, WeakPromise, delay.
  • React hooksuseSignalValue, useSignalValueEffect, useRunnerStatus, useRunnerStatusEffect, useRunnerError, useUpdate.

Subscription lifecycle

Subscriptions are tracked via WeakRef — if you don't keep a reference to the returned subscription, the garbage collector will eventually drop it and your callback will stop firing. Always store the subscription (in a variable, instance field, or hook ref) for as long as you want to receive updates.

// Wrong — subscription gets GC'd, callback stops working
counter.subscribe((v) => console.log(v));

// Right — held by `sub`, lives until you unsubscribe
const sub = counter.subscribe((v) => console.log(v));
sub.unsubscribe();

Scripts

npm run build         # vite + dts → dist/
npm run check:types   # tsc --noEmit
npm test              # vitest watch
npm run test:run      # vitest run (CI)

Origins

This package is a fork of @tcn/state (Copyright 2024 TCN). See NOTICE for upstream attribution.

License

Apache License 2.0 — see LICENSE.