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

@aihu/signals

v0.5.2

Published

Tiny reactive signals — the reactive primitive at the core of aihu.

Readme

@aihu/signals

Aihu — agentic discovery and interaction, for human purpose.

Tiny reactive signals — the reactive primitive at the core of aihu.

Part of the runtime core layer of the Aihu meta-framework. Shipped to the client; sized via bun run size. The runtime core is dep-free and stacks under @aihu/runtime → @aihu/router → @aihu/server → @aihu/app.

Small (≤ 2 kB gz) reactive primitives — the foundation layer for Aihu's arbor renderer. One read shape (signal tuple), one underlying cell. Sync semantics, lazy computed, explicit batch. No proxies, no scheduler queue, no global tick.

Hello counter

import { signal, effect } from '@aihu/signals'

const [count, setCount] = signal(0)
effect(() => console.log('count =', count()))
setCount(1)            // logs "count = 1"
setCount((n) => n + 10) // logs "count = 11"

Derived values with computed

import { signal, computed, effect } from '@aihu/signals'

const [n, setN] = signal(2)
const doubled = computed(() => n() * 2)

effect(() => console.log('doubled =', doubled())) // logs "doubled = 4"
setN(3)                                            // logs "doubled = 6"

computed is lazy: the body doesn't run until you read it. Subsequent reads return the cached value until a dep changes.

Atomic updates with batch

import { signal, effect, batch } from '@aihu/signals'

const [name, setName] = signal('')
const [email, setEmail] = signal('')

effect(() => save(name(), email()))   // runs once per save event

batch(() => {
  setName('Ada')
  setEmail('[email protected]')
})
// effect ran exactly once after the batch closed — not once per write.

batch returns void. To get a value out, capture it in a closure variable:

let id: string
batch(() => { id = insertRow(); setName('Ada') })

Cross-library cheat sheet

| Vue 3 | Solid | Preact Signals | aihu | |---|---|---|---| | ref(0) + .value | createSignal(0) → [get, set] | signal(0) + .value | signal(0) → [get, set] | | computed(fn) + .value | createMemo(fn) (eager) | computed(fn) + .value (lazy) | computed(fn) (lazy, call-shape) | | watchEffect(fn) → WatchHandle.stop() | createEffect(fn) (microtask) | effect(fn) → dispose | effect(fn) → dispose (sync) | | nextTick (no batch) | batch(fn) (returns) | batch(fn) (void) | batch(fn) (void) |

Untrack a read

import { signal, computed, untrack } from '@aihu/signals'

const [a, setA] = signal(1)
const [b, setB] = signal(10)

const sum = computed(() => a() + untrack(() => b()))
// sum tracks `a` only; setB updates won't recompute `sum`

Effect error isolation

When multiple effects fire in the same wave and one throws, sibling effects still run. The first thrown error rethrows directly; multiple thrown errors surface as AggregateError:

const [n, setN] = signal(0)
effect(() => { /* runs */ })
effect(() => { if (n() > 0) throw new Error('boom') })
effect(() => { /* still runs after sibling throws */ })

try { setN(1) } catch (e) { /* e is the original Error */ }

Computed-body throws bypass this path and continue to fail fast.

Storing functions in signals

Signal<T> for function-typed T requires the closure-of-closure idiom:

const [getFn, setFn] = signal<() => number>(() => 5)
setFn(() => 6)            // ❌ TypeScript error
setFn(() => () => 6)      // ✅ stores the function

The runtime disambiguates value vs updater by typeof === 'function', so a raw function is unambiguous only via the updater form. Mirrors SolidJS's Setter<T>. Detail: .team/phase-2/spec-signals-write-of-functions.md.

v0 limitations

  • Cycle errors carry no chain context. SignalCircularError is thrown synchronously from the writer; richer chain info lands with devtools.
  • No peek / onCleanup. Single-purpose primitives only; arbor's higher-level scopes live in @aihu/arbor.
  • Batch cascade cap. batch() re-iterates up to 100 times before throwing SignalCircularError. The cap is internal; if tooling needs to sanity-check legitimate cascade depth in the future, we'll re-export it.

Install

npm install @aihu/signals
# or
bun add @aihu/signals

Auto-generated against @aihu/[email protected].

Package facts

| | | |---|---| | Version | 0.5.2 | | Tier | A — Reactive runtime core — signals/computeds/effects | | Bundle size | 2.18 kB (gz) — limit 2350 B | | Published files | 3 entries | | License | MIT |

Auto-generated against @aihu/[email protected].

Exports

| Subpath | ESM | CJS | |---|---|---| | . | ./dist/index.js | — | | ./lifecycle | ./dist/lifecycle.js | — |

Auto-generated against @aihu/[email protected].

Dependencies

Zero runtime dependencies (per the dep-free thesis).

Auto-generated against @aihu/[email protected].

Server-Side Rendering (SSR)

@aihu/signals uses module-level reactive state (currentObserver, batchQueue, effectQueue, wave, and the link pool) that is shared across all concurrent requests in the same Node.js worker thread — it is not request-isolated by default.

If you use @aihu/signals in server-side code (via @aihu-plugin/data's resource() or directly):

  • Wrap all async operations inside effects with untrack() to prevent currentObserver from leaking across request boundaries during event-loop yields.
  • Do not hold live reactive graphs between requests — dispose effects when the request completes.
  • For true request isolation, instantiate signals within a request-scoped context rather than at module level.

Client-side usage (browser custom elements, arbor mounts) is unaffected — each tab is an isolated JS environment.

See also

Auto-generated against @aihu/[email protected].

License

MIT — see LICENSE.

Auto-generated against @aihu/[email protected].