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

bajo-emitter

v1.0.1

Published

Event emitter for Bajo Framework

Readme

bajo-emitter

Plugin name: bajoEmitter, alias: emitter

GitHub package.json version NPM Version

Attention: I do NOT accept any pull request at the moment, thanks!

Event emitter and message broker for Bajo based on the excellent EventEmitter2.

Installation

Goto your <bajo-base-dir> and type:

$ npm install bajo-emitter

Now open your <bajo-data-dir>/config/.plugins and add bajo-emitter in it

Configuration

Open/create <bajo-data-dir>/config/bajoEmitter.json:

| Key | Type | Required | Default | Description | | --- | ---- | -------- | ------- | ----------- | | maxListeners | integer | no | 100 | Max number of listeners that can be assigned to an event | | verboseMemoryLeak | boolean | no | false | Show event name in memory leak message when more than maximum amount of listeners is assigned | | ignoreErrors | boolean | no | false | Disable throwing uncaughtException if an error event is emitted and it has no listeners | | broadcastPools | array | no | [] | Broadcast pools | |   name | string | no | default | Pool name | |   from | string/array of string | yes || Source address(es) | |   to | string/array of string | no || Destinatin address(es) | |   handler | string | no || If not empty, messages are handled by this plugin helper instead of simply routed to to address(es) |

Note:

  • Only incoming messages from connections marked for broadcast will be processed
  • from should be one or more addresses with format <connection>@<plugin>. Only messages coming from one of these addresses are handled by this pool
  • to should be one or more addresses with format [subject:]<connection>@<plugin>
  • handler is a plugin helper name with format <plugin>:<helper>. If you use .js config file, you can attach a custom function instead.

Helper

function addressSplit (address)

  • A valid address should be in [<subject>:]<connection>@<plugin>
  • This helper destructs address into their components.
  • Returns object with the following keys:
    • plugin
    • connection
    • subject

function addressVerify (address, options)

  • Validate address of its components correctness. All options are optional:
    • skipConnectionCheck: won't check whether the connection is valid or not. Default: false
  • Returns true if address is valid, otherwise false

function emit (event, ...params)

  • Emit message as event named event
  • Zero, one or more parameters to emit
  • Returns none

function broadcast (params)

  • Send message as a broadcast
  • Parameters
    • msg: message to send
    • from: address from where message is originated
    • to: address to where message will be sent
    • subject: message subject
  • Returns none

Event Handling

To consume event emitted you should do these steps:

  • Create bajoEmitter/event/<eventType> directory inside your <bajo-plugin-dir>. Event type could be one of on, once and off
  • Create a file named [<plugin>@]<event>.js inside directory you just created above. <plugin> is optional, if not supplied, it defaults to current plugin
  • <event> is the name of event emitted. Name is then camel cased to form a valid event name
  • Write <bajo-handler> inside the above file

As an example, I use main plugin here and try to consume message event of bajoMqtt

  1. Directory structure:

    ...
    app
    |-- main
    |   |-- bajoEmitter
    |       |-- event
    |           |-- on
    |               |-- [email protected]
    ...
  2. Inside [email protected]:

    async function onBajoMqttMessage (conn, ...params) {
      const [topic, msg] = params
      console.log(topic, msg.toString())
    }
    
    export default onBajoMqttMessage

License

MIT