a little module for batch binding to event emitters

Usage no npm install needed!

<script type="module">
  import ebinder from 'https://cdn.skypack.dev/ebinder';



Build Status

a little module for batch binding to event emitters. just npm install ebinder.


var EventEmitter = require('events').EventEmitter;
var ebinder = require('ebinder');

var emitter = new EventEmitter();
var obj = {
    test: function(arg) {
        // arg == true
        // .. do something

// returns emitter
ebinder(emitter, obj);
emitter.emit('test', true);


(emitter, object, [optional]prefix)

Takes an EventEmitter and an Object, and for each property in the object that is of type function, we map it as a listener for an event on emitter by that name. Returns 'EventEmitter'. If [optional]prefix is given, each property will have prefix: in front of the property for the event name (ie: prop will bind to the event prefix:prop).