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

mikroevent

v1.0.1

Published

Ultra-lightweight, Node-native way to handle events, both in-process (as EventEmitter events) or across systems via HTTP(S).

Downloads

249

Readme

MikroEvent

Ultra-lightweight, Node.js-native way to handle events, both in-process (as EventEmitter events) or across systems via HTTP(S).

npm version

bundle size

Build Status

License: MIT


  • Node.js native solution to work with event-driven architecture
  • Easiest possible way to work with events in, or across, Node.js-based systems
  • None of the learning curve and overhead of other eventing options
  • Tiny (~1.2 KB gzipped)
  • Zero dependencies
  • High test coverage

Installation

npm install mikroevent -S

Usage

Quick Start

MikroEvent sends events to named targets using HTTP calls and/or internal, i.e. in-process events.

// ES5 format
const { MikroEvent } = require('mikroevent');
// ES6 format
import { MikroEvent } from 'mikroevent';

const mikroEvent = new MikroEvent();

mikroEvent.addTarget({
  name: 'internal',
  events: ['user.created']
});

const handler = () => { console.log('This runs in response to the user.created event') };

mikroEvent.on('user.created', handler);
//mikroEvent.once('user.created', handler); // Run event handler only once
//mikroEvent.off('user.created', handler);  // Remove event handler

await mikroEvent.emit('user.created', { id: '123', name: 'Test User' });

Check out the integration tests for a bigger, practical example of how MikroEvent works.

Updating a target

mikroEvent.updateTarget('system_a', { url: 'https://api.mydomain.com/userCreated', events: ['user.updated'] };

Add event to target

mikroEvent.addEventToTarget('system_a', ['user.updated', 'user.deleted']);

Removing a target

mikroEvent.removeTarget('system_a');

Receive events in the same system/process

Set up an event listener to react to events.

const handler = () => console.log('Run this when user.created is emitted');
mikroEvent.on('user.created', handler);

Receive events from other systems via HTTPS, transformed into an event

Handle an incoming event arriving over HTTP. Used for server integrations, when you want to manually handle the incoming event payload.

The processing will be async using process.nextTick() and running in a non-blocking fashion.

await mikroEvent.handleIncomingEvent({
  eventName: 'user.created',
  data: { id: '123', name: 'Test User' }
});

Receive events from other system via HTTPS

Create middleware for Express-style servers, i.e. using req and res objects. This is an approach that replaces using handleIncomingEvent() manually.

const middleware = mikroEvent.createMiddleware();
await middleware(req, res, next);

Configuration

You may also optionally instantiate MikroEvent with a custom error handling function.

const errorHandler = () => console.error('Run this on errors');
const mikroEvent = new MikroEvent({ errorHandler });

You can mute any non-critical message with the isSilent property set to false.

const mikroEvent = new MikroEvent({ isSilent: false });

License

MIT. See LICENSE file.