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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jaxs-bus

v0.1.3

Published

Small message bus and a package used by jaxs (for pub/sub)

Downloads

2

Readme

jaxs-bus

Small message bus and a package used by jaxs (for pub/sub).

There is a surprising absence of small and flexible message buses for the client side. This is a small but purpose built message bus. The purpose is to decouple rendering in jsx from any other concerns in the Jaxs library. It could be used for other things, because it's just a little message bus.

Features

The main joy of this little library is that it can match event names via:

  • an exact string match
  • a regex

A lot of other libraries build little namespacing DSLs, but for me the superset of needs is fuzzy vs exact matches. How the fuzzy matches happens is up to you via regexes which are powerful and sometimes even expressive.

import { createBus } from 'jaxs-bus'

const exactListener = (payload, listenerOptions) => {
  console.log(`Exact listener: ${listenerOptions.eventName} ${payload}`)
}

const fuzzyListener = (payload, listenerOptions) => {
  console.log(`Fuzzy listener: ${listenerOptions.eventName} ${payload}`)
}

const bus = createBus()
bus.subscribe('exactly', exactListener)
bus.subscribe(/ex.*/, fuzzyListener)

bus.publish('extra', 'extra-payload')
// logged string:
//  Fuzzy listener: extra extra-payload

bus.publish('exactly', 'exactly-payload')
// logged string:
//  Exact listener: exactly exactly-payload
//  Fuzzy listener: exactly exactly-payload

Fuzzy listeners are good for things that could be called middleware. For example, if you wanted to debug events passing through the system you could subscribe to everything and log out the data you were interested in understanding:

const unsubscribe = bus.subscribe(/.*/, console.log)

When you are done with your debuggery, you can go ahead and unsubscribe and the logging will stop.

unsubscribe()

Another good use of fuzzy matcher would be something that does something before or after certain events. For example, if you were to create a data namespace, and everytime a prefaced data event comes in you could save to local storage.

bus.subscribe(/data:+./, saveToLocalStorage)

bus.publish('not-relevant', {ignore: 'me'}) // ignored by storage efforts
bus.publish('data:new-user', {user: {name: 'Kane'}}) // calls function!

Installation

This is an npm module at npmjs. Use your favorite package manager to download and consume.

It is setup for both umd and es6 imports, plus a types file.

It's also very small, dist js is 75 brief lines.