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

alien-projections

v0.1.3

Published

Incremental reactive collection transforms for the alien-signals ecosystem

Readme

alien-projections

Incremental reactive collection transforms for the alien-signals ecosystem.

When one item in a large collection changes, only that item's mapped output is recomputed — not the entire collection.

Install

bun add alien-projections alien-signals

alien-signals is a peer dependency.

Usage

import { signal } from "alien-signals"
import { createProjection } from "alien-projections"

const items = signal([
  { id: "1", text: "Buy milk", done: false },
  { id: "2", text: "Fix bug", done: true },
])

// Incremental projection — only re-maps changed entries
const projection = createProjection(items, {
  key: (item) => item.id,
  map: (item) => ({ ...item, upper: item.text.toUpperCase() }),
  filter: (item) => !item.done,
  sort: (a, b) => a.text.localeCompare(b.text),
})

// Read the projected collection
console.log(projection())
// [{ id: "1", text: "Buy milk", done: false, upper: "BUY MILK" }]

API

createProjection(source, options)

Creates an incremental reactive projection over a signal-backed collection.

Parameters:

  • source: Signal<T[]> — A readable signal containing the source array.
  • options.key: (item: T) => K — Extract a stable identity key from each item. Used to track additions, removals, and changes.
  • options.map?: (item: T) => U — Transform each item. Only re-executed when an item is new or its reference changed. Defaults to identity.
  • options.filter?: (mapped: U) => boolean — Predicate applied after mapping. Items that fail are excluded.
  • options.sort?: (a: U, b: U) => number — Comparator applied after map and filter.

Returns: Signal<U[]> — A computed signal producing the projected collection.

How incremental updates work

On each recomputation:

  1. The source array is iterated by key.
  2. For each item, if the cache holds an entry with the same reference, the cached output is reused (no map call).
  3. New or changed items (different reference) are mapped and cached.
  4. Stale cache entries (keys no longer in source) are evicted.
  5. Filter and sort are applied to produce the final output.

This means that if you have 10,000 items and change one, only that one item's map function runs.

Credits & Inspiration

Compatibility

This package is not API-compatible with SolidJS projections or Signia. It follows alien-signals conventions (callable accessors, computed() return type) and provides a broader API (filter + sort alongside map). SolidJS createProjection focuses on key-indexed UI reconciliation; this package targets general incremental collection transforms.

See Also

  • alien-resources — Async signal bridge for alien-signals. createResource(fetcher) with loading/error states and automatic cancellation. The companion package for async data.
  • @silvery/signals — The Silvery TUI framework includes alien-projections and alien-resources as part of its @silvery/signals package, adding React integration (useSignal), deep stores (createStore), and model factories on top.

License

MIT