items().sort() just mutated your state. sortBy does not.
Filter, sort, group, search, sum: 43 functions in one package. Pass a signal and get a live computed back; pass a plain array and get an array. Derived lists become one line each, they never mutate the source, and pipe runs a whole chain as one reactive node.
bun add @pyreon/rx - functions
- 43Collections, set operations, aggregation, operators, timing, search and
pipe. - in → out
- signal → computedA plain array in gives a plain array out.
pipe- 1 node for N stagesAn exact count, not a timing.
- iOS and Android
- shared tierSupported transforms lower to native collection operations; an unsupported one warns by name.
- 1 reactive node for a three-stage
pipe, where separate calls build threeBENCHMARKS.md §10, rx row: "pipefuses N nodes into 1 (exact count)" · final pass - 43 signal-aware functions in one package,
pipeincludedpackages/fundamentals/rx/src/index.ts,rxnamespace
synthetic · author-run · M3 Max · record of 2026-11-05
Every result, including where we lose →Derived data, minus the footguns.
Never mutates the source
sortBysorts a copy and compares numbers as numbers, so[1, 10, 2]comes back[1, 2, 10]. A hand-writtenitems().sort()inside acomputedreorders the signal's own array.One function, two modes
filter(users, fn)with a signal returns aComputedthat re-derives whenuserschanges.filter(list, fn)with an array returns an array. Same import on the server, in tests and in components.pipeis one nodepipe(products, inStock, byPrice, top3)is one computed: one subscription, one recompute per change. Three separate calls make three nodes and three hops.Timers that clean up
debounce(query, 300)gives a signal that settles 300 ms after the last keystroke. Inside a component its effect and pending timer go away on unmount.
Three computeds, one bug, or one pipe.
A computed per step. Forget the [...] copy and the sort reorders inStock's cached array in place.
const inStock = computed(() =>
products().filter((p) => p.stock > 0))
const byPrice = computed(() =>
[...inStock()].sort((a, b) => a.price - b.price))
const top3 = computed(() => byPrice().slice(0, 3))One computed for the chain. Each stage is a plain function; rx helpers on plain arrays return plain arrays.
import { pipe, sortBy, take } from '@pyreon/rx'
const top3 = pipe(
products,
(items) => items.filter((p) => p.stock > 0),
(items) => sortBy(items, 'price'),
(items) => take(items, 3),
)
top3() // ['Desk lamp', 'Monitor arm', 'Mechanical keyboard']
products.update((ps) => [...ps, plantPot])
top3() // ['Plant pot', 'Desk lamp', 'Monitor arm']Coming from RxJS?
A filtered, debounced list without a subscription.
import { BehaviorSubject, combineLatest, debounceTime, map } from 'rxjs'
const products$ = new BehaviorSubject<Product[]>(initial)
const query$ = new BehaviorSubject('')
const visible$ = combineLatest([
products$,
query$.pipe(debounceTime(300)),
]).pipe(
map(([items, q]) =>
items.filter((p) => p.name.toLowerCase().includes(q.toLowerCase()))),
map((items) => [...items].sort((a, b) => a.price - b.price)),
)
const sub = visible$.subscribe(render)
// later: sub.unsubscribe()@pyreon/rx is not RxJS. RxJS is push-based streams over time: events, HTTP, cancellation with switchMap, schedulers, backpressure. @pyreon/rx is pull-based derivation of the current value of a signal, plus debounce, throttle, scan and distinct for signals. Keep RxJS for event streams; for "a list that depends on other state" this is less code. For requests, use @pyreon/query.
import { For } from '@pyreon/core'
import { signal } from '@pyreon/reactivity'
import { debounce, search, sortBy } from '@pyreon/rx'
const products = signal<Product[]>(initial)
const query = signal('')
function ProductList() {
// built in the component: the debounce's effect and timer go away on unmount
const visible = sortBy(search(products, debounce(query, 300), ['name']), 'price')
// no subscribe, no unsubscribe
return (
<ul>
<For each={visible()} by={(p) => p.id}>{(p) => <li>{p.name}</li>}</For>
</ul>
)
}Search, sort and group a live list.
One pipe over a products signal: search, sort and group. The counter shows how many times the pipe recomputed: once per change, however many stages it has.
pipe(
products,
(xs) => search(xs, query(), ['name', 'cat']),
(xs) => sortBy(xs, key(), dir()),
(xs) => (grouped() ? groupBy(xs, 'cat') : xs),
)
// query() = '', grouped() = false
// key() = 'name', dir() = 'asc'- pipe recomputes1
12 of 12 products
- Cast iron panKitchen$45
- Chef knifeKitchen$95
- Coffee grinderKitchen$89
- Desk lampHome$39
- Desk matOffice$29
- Mechanical keyboardTech$129
- Monitor armOffice$119
- Noise headphonesTech$249
- Plant potHome$19
- Standing deskOffice$489
- Throw blanketHome$59
- USB-C dockTech$179
A pipeline costs one node, not N.
The record's fair peer is the computed you would write without rx; RxJS appears in the harness only as scale context, not as a race. pipe fusing three stages into one node is an exact count. For three rows the harness prints medians with no confidence interval, so the record gives no verdict.
computed and Solid createMemo · 1,000 rows, bun/JavaScriptCorePyreonrival · lower is better- reactive nodes for a three-stage chainwinexact count, not a timing
- filter, map, summeasuredlevel with or ahead of a hand computed
pipe, three stagesmeasured1.03×, no CI: no verdictsortBymeasured1.03×, no CI: no verdictgroupBymeasured1.02×, no CI: no verdict
43 functions, grouped the way you think.
- Collections
filter,map,flatMap,sortBy(asc or desc),groupBy,countBy,keyBy,uniqBy,partition,chunkand more. - Slicing
take,skip,first,last,takeWhile,dropWhile,sample. - Set operations
intersection,difference,union, reactive on both inputs. - Aggregation
count,sum,min,max,average,reduce,every,some.sum,min,maxandaveragetake a key or a selector. search(source, query, keys)Case-insensitive match across the fields you name; the query can be a signal.debounce/throttleSignals that settle; torn down with the component, or.dispose()outside one.scan/distinctRunning totals, and a signal that only notifies on a real change.combine/zip/mergeJoin several signals: one function over their values, pairs by index, or one concatenated list.pipeA whole chain in one computed node, typed stage by stage up to seven.rx.*or named imports A namespace for dot-notation, named exports for tree-shaking: the same functions.
Things to build with it.
Totals, counts per category and groups, each a live computed over the same signal.
import { countBy, groupBy, sum } from '@pyreon/rx'
const revenue = sum(orders, 'total')
const perStatus = countBy(orders, 'status')
const byRegion = groupBy(orders, 'region')
const Tile = () => (
<section>
<h3>{() => revenue().toFixed(2)}</h3>
<p>{() => perStatus().paid ?? 0} paid</p>
<p>{() => Object.keys(byRegion()).length} regions</p>
</section>
)The intersection of what is selected and what is still in the list, live on both sides.
import { signal } from '@pyreon/reactivity'
import { intersection } from '@pyreon/rx'
const visibleIds = signal([1, 2, 3])
const selectedIds = signal([2, 3, 4])
const stillSelected = intersection(visibleIds, selectedIds)
stillSelected() // [2, 3]
selectedIds.set([3])
stillSelected() // [3]43 functions and a namespace.
Every export has a reference page with its signature, an example and the mistakes people make with it.
- pipe
- rx
- filter
- map
- flatMap
- sortBy
- groupBy
- countBy
- keyBy
- uniqBy
- unique
- partition
- chunk
- flatten
- compact
- reverse
- find
- mapValues
- take
- skip
- first
- last
- takeWhile
- dropWhile
- sample
- intersection
- difference
- union
- count
- sum
- min
- max
- average
- reduce
- every
- some
- distinct
- scan
- combine
- zip
- merge
- debounce
- throttle
- search
- ReadableSignal
- KeyOf
Good to know before you start.
Pass the signal, not its value
filter(users, fn) is live. filter(users(), fn) runs once and never updates, because detection is typeof source === 'function'.
Outside a component, dispose timers
debounce, throttle, distinct and scan own an effect. In a component or effectScope it is torn down for you; elsewhere call .dispose().
search reads string fields
search matches only fields whose value is a string, so a number or a nested object in keys never matches. Map it to a string field first, or use filter with your own test.
Not a stream library
No switchMap, no schedulers, no cancellation. For events over time and request racing, RxJS still fits; for server data, @pyreon/query.
What people ask first.
Is this RxJS for signals?
No. It is collection helpers, lodash-style, that understand signals. The benchmark races it against a hand-written computed and Solid's createMemo; RxJS appears there only as scale context, because it solves a different problem.
Is it slower than writing the computed myself?
Filter, map and sum measure level with or ahead of a hand-written computed. pipe of three stages and sortBy read 1.03× behind a hand computed, groupBy 1.02× behind, but the harness prints medians without confidence intervals there, so the record gives them no verdict.
When should I use pipe?
For a chain of two or more steps that nothing else reads in between. It builds one node instead of one per step. If you need an intermediate result elsewhere, keep that step as its own computed.
Does it work on iOS and Android?
The package is in the shared tier: supported transforms, namespaced or imported by name, lower to native collection operations, and an unsupported one warns by name. Native targets are experimental.
Your computed was fine. It just did not need to be written.
bun add @pyreon/rx