events-light
v1.0.5
Published
Lightweight and fast implementation of the 'events' module for the browser and server.
Downloads
19,363
Readme
events-light
This is a lighter and small version of the builtin Node.js events with some removals, but no additional features. This module was designed to be a trimmed down polyfill for the events
module in the browser, but it can also be used on the server.
Install
npm install events-light --save
Usage
var EventEmitter = require('events-light');
var myEventEmitter = new EventEmitter();
myEventEmitter.on('hello', function(name) {
console.log('Hello ' + name);
});
myEventEmitter.emit('hello', 'World');
Difference from the Node.js events
module
- Much smaller
- Slightly different error messages
- Removed:
EventEmitter.defaultMaxListeners
EventEmitter.listenerCount(emitter, eventName)
Event: 'removeListener'
Event: 'newListener'
emitter.prependOnceListener(eventName, listener)
emitter.setMaxListeners(n)
emitter.addListener(eventName, listener)
(useon
instead)emitter.listenerCount(eventName)
emitter.listeners(eventName)
License
MIT