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

uevent

v3.0.0

Published

Event emitter micro library

Readme

uEvent

npm version jsDelivr CDN GZIP size Build Status

uEvent is a event emitter library which provides the observer pattern to javascript objects. It works on node.js and browser and also supports RequireJS (AMD).

It is a fork of jeromeetienne/microevents.js with the changes of few other forks and custom changes.

Features

  • jQuery-like API (on, off, once, trigger)
  • Value modifier support
  • prevent default and stop propagation patterns
  • handleEvent support

Installation

$ npm install uevent

Usage

Create an emitter

Direct

import { EventEmitter } from 'uevent';

const obj = new EventEmitter();

Class extend

class Manager extends EventEmitter {

}

class obj = new Manager();

Mixin

import { mixin as eventEmitterMixin } from 'uevent';

const obj = {};

eventEmitterMixin(obj);

Register event handlers

on

Add one or many event handlers.

// bind 'callback' to 'event'
obj.on('event', callback);

// bind 'callback' to 'event1' and 'event2'
obj.on('event1 event2', callback);

// bind 'callback1' to 'event1' and 'callback2' to 'event2'
obj.on({
  event1: callback1,
  event2: callback2
});

off

Remove one or many or all event handlers.

// remove all callbacks for 'event'
obj.off('event');

// remove 'callback' if attached to 'event'
obj.off('event', callback);

// remove all callbacks for 'event1' and 'event2'
obj.off('event1 event2');

// remove 'callback1' if attached to 'event1' and 'callback2' if attached to 'event2'
obj.off({
  event1: callback1,
  event2: callback2
});

// remove all callbacks
obj.off();

once

Same as on but the callbacks will be removed after the first invocation.

The callbacks attached once are only called by trigger and not by change.

Callback signature

The first parameter of the callback is always an Event object having the following properties :

  • type the name of the event
  • target the source object of the event
  • args additional parameters

When additional parameters are provided they are passed to the callback :

const callback = function(event, param1, param2) {};

When using the handleEvent feature you only get the event object :

const listener = {
    handleEvent: function(event) {}
};

Trigger events

trigger

Trigger all handlers for an event. Accept optional arguments transmitted to the callbacks.

// trigger 'event'
obj.trigger('event');

// trigger 'event' with arguments
obj.trigger('event', true, 42);

change

Works like trigger but returns a value. This is used to filter a value before display for example. All callbacks must accept at least on input value and return the modified (or not) value.

// call 'event' filters with 'Hello world' input
var newVal = obj.change('event', 'Hello world')

// call 'event' filters with 'Hello world' input and other arguments
var newVal = obj.change('event', 'Hello world', true, 42)

The Event object has an additional value property which holds the current value.

Advanced

Prevent default

Call preventDefault() on this Event object to "mark" the event. After calling trigger you get a reference to this Event object and can test isDefaultPrevented().

obj.on('event', function(e, id) {
  if (id == 0) {
    e.preventDefault();
  }
});

const e = obj.trigger('event', id);

if (!e.isDefaultPrevented()) {
  // ...
}

Stop propagation

Call stopPropagation() on the Event object to prevent any further callbacks to be called. Works for trigger and change.

obj.on('event', function(e, val) {
  e.stopPropagation();
  return val;
});

obj.on('event', function(e, val) {
  return 'azerty';
});

const newVal = obj.change('event', '1234');
// newVal is still '1234'

License

This library is available under the MIT license.