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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@larcjs/core-routing

v2.0.0

Published

Dynamic message routing system for LARC Core (8KB add-on)

Readme

@larcjs/core-routing

Version License Bundle Size

Dynamic message routing system - Declarative routing rules for PAN messages

Add powerful message routing capabilities to LARC Core or Core Lite. Configure message flows declaratively at runtime without hardcoding logic in components.

Installation

# Requires @larcjs/core or @larcjs/core-lite
npm install @larcjs/core-routing

Quick Start

<pan-bus enable-routing="true"></pan-bus>

<script type="module">
import '@larcjs/core-routing';

// Access routing manager
const routes = window.pan.routes;

// Add a route
routes.add({
  name: 'High Temperature Alert',
  match: {
    type: 'sensor.temperature',
    where: { op: 'gt', path: 'payload.value', value: 30 }
  },
  actions: [
    { type: 'EMIT', message: { type: 'alert.highTemp' }, inherit: ['payload'] },
    { type: 'LOG', level: 'warn', template: 'High temp: {{payload.value}}°C' }
  ]
});
</script>

Features

  • 🎯 Declarative Routing - Define message flows as configuration
  • 🔀 Multiple Actions - Chain EMIT, LOG, FORWARD, CALL actions
  • 🔍 Powerful Matching - Pattern matching with complex predicates
  • 🔄 Transform Messages - Pick, map, or custom transformations
  • Runtime Configuration - Add/update/remove routes on the fly
  • 📊 Statistics - Track routing performance and matches

Use Cases

Analytics Tracking

routes.add({
  name: 'Track User Events',
  match: { tagsAny: ['trackable'], type: ['user.click', 'user.view'] },
  actions: [{ type: 'FORWARD', topic: 'analytics.events' }]
});

Smart Notifications

routes.add({
  name: 'VIP Order Priority',
  match: {
    type: 'order.created',
    where: {
      op: 'and',
      children: [
        { op: 'gte', path: 'payload.total', value: 1000 },
        { op: 'eq', path: 'payload.customerTier', value: 'vip' }
      ]
    }
  },
  actions: [
    {
      type: 'EMIT',
      message: {
        type: 'notification.vip-order',
        payload: { priority: 'high', channels: ['email', 'sms'] }
      }
    }
  ]
});

Feature Flags

routes.registerHandler('feature-router', (msg) => {
  const flags = getFeatureFlags();
  const topic = flags.newUI ? 'ui.v2' : 'ui.v1';
  window.pan.bus.publish(topic, msg.payload);
});

routes.add({
  name: 'Feature Flag Router',
  match: { type: 'app.init' },
  actions: [{ type: 'CALL', handlerId: 'feature-router' }]
});

API Reference

routes.add(config)

Add a new route.

const route = routes.add({
  name: 'My Route',
  match: { /* matching rules */ },
  transform: { /* optional transform */ },
  actions: [ /* actions to execute */ ]
});

routes.update(id, changes)

Update an existing route.

routes.update(route.id, { enabled: false });

routes.remove(id)

Remove a route.

routes.remove(route.id);

routes.list()

Get all routes.

const allRoutes = routes.list();
console.table(allRoutes);

routes.getStats()

Get routing statistics.

console.log(routes.getStats());
// {
//   routesEvaluated: 1234,
//   routesMatched: 456,
//   actionsExecuted: 789
// }

Predicates

Available operators for matching:

  • Comparison: eq, ne, gt, gte, lt, lte
  • String: startsWith, endsWith, contains, matches (regex)
  • Logic: and, or, not
  • Membership: in, notIn
  • Existence: exists, notExists

Actions

  • EMIT - Publish a new message
  • FORWARD - Forward to another topic
  • LOG - Log message (console.log/warn/error)
  • CALL - Call a registered handler function

Performance

  • Sub-millisecond message evaluation
  • Efficient predicate matching
  • Minimal overhead when no routes match

Bundle Size

  • Minified: 8.3KB
  • Gzipped: ~3KB

Related Packages

License

MIT © Chris Robison