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

@the-link/core

v0.3.1

Published

Composable bidirectional event routing primitives.

Downloads

432

Readme

The Link Core

Composable bidirectional event routing without a transport or application model. Core provides the primitives shared by every The Link adapter: tunnels, links, synchronized properties, method decorators, and optional byte utilities.

Install

npm install @the-link/core

Tunnel

A Tunnel publishes named events and aggregates the values returned by their handlers.

import { Tunnel } from "@the-link/core"

const tunnel = new Tunnel()

tunnel.subscribe("sum", (left: number, right: number) => left + right)

const total = await tunnel.publishFirst<number>("sum", 20, 22)

console.log(total) // 42

Every publication passes through four ordered phases:

  1. Interceptors transform or reject the payload.
  2. Subscribers handle the exact event.
  3. Forwarders route matching event prefixes.
  4. Finalizers transform the aggregated results.

Registration methods return cleanup functions, so routing can be composed and removed without retaining separate listener bookkeeping.

const unsubscribe = tunnel.subscribe("status", console.log)

await tunnel.publish("status", "ready")
unsubscribe()

subscribeOnce(), waitFor(), and waitFirst() cover one-time and awaitable events. forwardTo() connects a tunnel or forwarding function and can rewrite the matching event prefix.

TheLink

TheLink is the transport-neutral unit built from two tunnels:

  • $outbound carries events toward an adapter or another routing layer.
  • $inbound carries events received from an adapter or another routing layer.

Links compose through subscribeTo(), publishTo(), and connectTo(). Prefix arguments create namespaces while the returned cleanup function removes the relationship.

import { TheLink } from "@the-link/core"

const application = new TheLink()
const account = new TheLink()

const disconnect = application.connectTo(account, "", "account:")

disconnect()

Core does not decide what an event means or which transport carries it. The HTTP, IPC, Worker, Frame, and Tab packages adapt this same contract to concrete communication boundaries.

Properties

Property synchronizes one provider-owned value through a link. A public provider accepts update requests; a private provider rejects them. Consumers bind to the provider's generated key.

import { Property, TheLink } from "@the-link/core"

const providerLink = new TheLink()
const consumerLink = new TheLink()

providerLink.$outbound.forwardTo(consumerLink.$inbound)
consumerLink.$outbound.forwardTo(providerLink.$inbound)

const theme = Property.public(providerLink, "light")
const snapshot = theme.toJSON()

const remoteTheme = Property.consumer(consumerLink, snapshot.key, snapshot.value)

remoteTheme.tunnel.subscribe("change", value => console.log(value))
await theme.update("dark")

The links must already be connected through the routing or transport topology. Each property exposes its current value, public key, local change tunnel, and an optional inbound interceptor.

Decorators

The ECMAScript decorators register methods against a link during construction:

import { TheLink } from "@the-link/core"
import { Subscribe } from "@the-link/core/decorators"

class ApplicationLink extends TheLink {
    @Subscribe("greet")
    async greet(name: string) {
        return `Hello ${name}`
    }
}

The available decorators are Intercept, Subscribe, Forward, Finalize, Publish, and Connect. Projects that still compile TypeScript's legacy decorator form can import the compatible implementations from @the-link/core/decorators/legacy.

JSON bytes

serializeJSON() and deserializeJSON() provide the equivalent of JSON stringification and parsing over UTF-8 bytes:

import { deserializeJSON, serializeJSON } from "@the-link/core"

const bytes = serializeJSON({ ready: true })
const value = deserializeJSON(bytes)

They are utilities, not part of Link routing. Adapters may use them, replace them, or operate without them.

Entry points

| Import | Contract | | --- | --- | | @the-link/core | links, tunnels, properties, JSON byte utilities, and their types | | @the-link/core/decorators | ECMAScript decorators | | @the-link/core/decorators/legacy | legacy TypeScript decorators |

Development

bun install --frozen-lockfile
bun run verify

License

MIT