Sha256: 2e504568e082a5e36ae48ee0c8d54388d696df8776bd8c83808c4b6a1e6ebdc1
Contents?: true
Size: 762 Bytes
Versions: 17
Compression:
Stored size: 762 Bytes
Contents
function EmitterWrapper(emitter) { this.listeners = {}; this.emitter = emitter; } EmitterWrapper.prototype.addListener = EmitterWrapper.prototype.on = function(event, listener) { this.emitter.addListener(event, listener); if (!this.listeners.hasOwnProperty(event)) { this.listeners[event] = []; } this.listeners[event].push(listener); return this; }; EmitterWrapper.prototype.removeAllListeners = function(event) { var events = event ? [event] : Object.keys(this.listeners); var self = this; events.forEach(function(event) { self.listeners[event].forEach(function(listener) { self.emitter.removeListener(event, listener); }); delete self.listeners[event]; }); return this; }; module.exports = EmitterWrapper;
Version data entries
17 entries across 17 versions & 2 rubygems