node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


Combines multiple event emitters into a single emitter


Combines multiple event emitters into a single emitter.

Lead Maintainer - Emily Rose


$ npm install --save kilt

Instantiate a kilt instance with the event emitters to combine and listen for events on the new kilt instance. Kilt derives from EventEmitter and may also be used to emit events.

var Events = require('events');
var Kilt   = require('kilt');
var emitter1 = new Events.EventEmitter();
var emitter2 = new Events.EventEmitter();
var kilt = new Kilt([emitter1, emitter2]);
// A single handler for both emitters. 
kilt.on('hello', function (data) {
// Emit events from multiple emitters. 
emitter1.emit('hello', 'Hello from emitter1');
emitter2.emit('hello', 'Hello from emitter2');
// Emit a event using kilt. 
kilt.emit('hello', 'Hello from Kilt');


Hello from emitter1
Hello from emitter2
Hello from kilt

Kilt constructor which accepts optional emitters to manage.

var kilt = new Kilt();
... = new Kilt(emitter);
... = new Kilt([emitter]);
... = new Kilt([emitter1, emitter2]);

Add an emitter for kilt to manage.

var emitter = new Events.Emitter();

Attach a listener to all emitters with the specified type.

kilt.on('example', function (data) {

Attach a listener to all emitters with the specified type that will only fire once.

kilt.once('example', console.log.bind(console, '"example" event emitted once with data:'));

Remove the specified listener.

var emitter = new Events.Emitter();
var listener = function () {
// Attach listener. 
kilt.on('example', listener);
// Remove listener. 
kilt.removeListener('example', listener);

Remove all listeners. Optionally, you may specify the type of listeners to remove.

// Attach listeners. 
kilt.on('example', ...);
kilt.on('example', ...);
kilt.on('example', ...);
kilt.on('other', ...);
// Only remove listeners of a specific type. 
// Remove all listeners. 

Emit the specified event with the specified, optional data.

var emitter = new Events.Emitter();
var kilt = new Kilt(emitter);
// Attach listener. 
kilt.on('example', console.log.bind(console, '"example" event emitted with data:'));
// Emit event on kilt. 
kilt.emit('example', 'emitted');