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

Version Path
hooch-0.4.2 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.4.1 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.4.0 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.3.0 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.2.1 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.2.0 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.1.0 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.0.8 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.0.7 jasmine/node_modules/karma/lib/emitter_wrapper.js
hooch-0.0.6 jasmine/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/lib/emitter_wrapper.js