Emits received events from event stream on a normal event emitter with prefix
@param {events.EventEmitter} listener - Event Emitter
@param {string} [eventPrefix=""] - Prefix streamed events with this prefix on event emitter
@returns {EventStream}
546719
function (listener, eventPrefix) {
        var lastName;

        eventPrefix = eventPrefix || '';

        this.receive({
            test: function (val) {
                lastName = val;
                return true;
            }
        }, function (data) {
            listener.emit(eventPrefix + lastName, data);
        });
        return this;
    }
521140
function hasCompleteEventParams(eventType, listener) {
        var hasParams = eventType && listener,
            isTypeString = typeof eventType === 'string',
            isTypeFunction = typeof listener === 'function';

        if (!isTypeFunction) {
            throw new TypeError(EventDispatcher.TYPE_ERROR);
        }

        return hasParams && isTypeString && isTypeFunction;
    }
332171
function EventEmitter() {
  this._events = { };
  this._once   = { };
  // default to 10 max liseners
  this._maxListeners = 10;

  this._add = function (event, listener, once) {
    var entry = { listener: listener };
    if (once) {
      entry.once = true;
    }

    if (this._events[event]) {
      this._events[event].push(entry);
    } else {
      this._events[event] = [ entry ];
    }

    if (this._maxListeners && this._events[event].count > this._maxListeners && console && console.warn) {
      console.warn("EventEmitter Error: Maximum number of listeners");
    }

    return this;
  };

  this.on = function (event, listener) {
    return this._add(event, listener);
  };

  this.addListener = this.on;

  this.once = function (event, listener) {
    return this._add(event, listener, true);
  };

  this.removeListener = function (event, listener) {
    if (!this._events[event]) {
      return this;
    }

    for(var i = this._events.length-1; i--;) {
      if (this._events[i].listener === callback) {
        this._events.splice(i, 1);
      }
    }

    return this;
  };

  this.removeAllListeners = function (event) {
    this._events[event] = undefined;

    return this;
  };

  this.setMaxListeners = function (count) {
    this._maxListeners = count;

    return this;
  };

  this.emit = function () {
    var args = Array.prototype.slice.apply(arguments);
    var remove = [ ], i;

    if (args.length) {
      var event = args.shift();

      if (this._events[event]) {
        for (i = this._events[event].length; i--;) {
          this._events[event][i].listener.apply(null, args);
          if (this._events[event][i].once) {
            remove.push(listener);
          }
        }
      }

      for (i = remove.length; i--;) {
        this.removeListener(event, remove[i]);
      }
    }

    return this;
  };
}
643900
function emitSDAMEvent(self, event, description) {
  if (self.listeners(event).length > 0) {
    self.emit(event, description);
  }
}
1277742
function(eventType, listener) {
    var i, len, foundIndex, events, perEventHandlers;
    if (arguments.length === 0) {
      events = _keys(_handlers);
    } else if (typeof eventType === "string" && eventType) {
      events = eventType.toLowerCase().split(/\s+/);
    } else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
      _keys(eventType).forEach(function(key) {
        var listener = eventType[key];
        if (typeof listener === "function") {
          ZeroClipboard.off(key, listener);
        }
      });
    }
    if (events && events.length) {
      for (i = 0, len = events.length; i < len; i++) {
        eventType = events[i].replace(/^on/, "");
        perEventHandlers = _handlers[eventType];
        if (perEventHandlers && perEventHandlers.length) {
          if (listener) {
            foundIndex = perEventHandlers.indexOf(listener);
            while (foundIndex !== -1) {
              perEventHandlers.splice(foundIndex, 1);
              foundIndex = perEventHandlers.indexOf(listener, foundIndex);
            }
          } else {
            perEventHandlers.length = 0;
          }
        }
      }
    }
    return ZeroClipboard;
  }
650204
function listeners(type) {
      var object = this,
          events = object.events || (object.events = {});

      return _.has(events, type) ? events[type] : (events[type] = []);
    }
31340
function getEmitter(config) {
      function Emitter(n) {
        n = n || this;
        n.__events = n.__events || {};
        n.__once = n.__once || {};
      }

      Emitter.prototype.on = function(name, fn) {
        fn = fn || Function();
        this.__events[name] = (this.__events[name] || [])
        this.__events[name].push(fn);
      }

      Emitter.prototype.once = function(name, fn) {
        fn = fn || Function();
        this.__once[name] = (this.__once[name] || []);
        this.__once[name].push(fn);
      }

      Emitter.prototype.off = function(name, fn) {
        var i;

        fn = fn || Function();
        i = (this.__events[name] || []).indexOf(fn);
        if (~i) this.__events[name].splice(i, 1);

        i = (this.__once[name] || []).indexOf(fn);
        if (~i) this.__once[name].splice(i, 1);
      }

      Emitter.prototype.emit = function(name) {
        var args = [].slice.call(arguments),
            es = (this.__events[name] || []).slice(),
            i, self = this;

        args.shift();
        es.push.apply(es, this.__once[name] || []);

        for (i = 0; i < es.length; i++) {
          es[i].apply(self, args);
        }

        this.__once[name] = [];
      }

      Emitter.prototype.emitCtx = function(name, ctx) {
        var args = [].slice.call(arguments),
            es = (this.__events[name] || []).slice(),
            i, self = this;

        args.shift(); args.shift();
        es.push.apply(es, this.__once[name] || []);

        for (i = 0; i < es.length; i++) {
          es[i].apply(ctx, args);
        }

        this.__once[name] = [];
      }

      return Emitter;
    }
918863
function createEventEmitterCallback(event, emitter) {
    return function (ex) {
        if (ex) {
            emitter.emit('error', ex);
        } else {
            var args = Array.prototype.slice.call(arguments);
            args[0] = event;
            emitter.emit.apply(emitter, args);
            if (event == 'end') {
                emitter.removeAllListeners();
            }
        }
    };
}
619316
function Emitter(constructor) {
  if("function" == typeof constructor) {
    constructor(emit)
  }else{
    constructor = null
  }
  
  var listeners = []

  // emitter(listener:Function) -> removeListener:Function
  // emitter() -> emitter:function
  var emitter = function (listener) {
    // emitter() -> emitter:function
    if(!listener) {
      return emitter
    }
    // emitter(listener:Function) -> removeListener:Function
    if("function" !== typeof listener) {
      throw new Error('Listener must be a function')
    }
    var newLength = listeners.push(listener)
      , index = newLength-1
      , removed = false
    
    return function removeListener() {
      if(removed) return
      removed = true
      listeners.splice(index, 1)
    }
  }
  
  if(!constructor) {
    // emitter.emit(args...)
    emitter.emit = emit
  }
  
  return emitter
  
  function emit() {
    var args = arguments
    listeners.forEach(function(listener) {
      listener.apply(null, args)
    })
  }
}
225805
function (name, fn, ctx) {
        assert(isString(name), 'EventEmitter#on: name is not a string');
        assert(isFunction(fn), 'EventEmitter#on: fn is not a function');

        // If the context is not passed, use `this`.
        ctx = ctx || this;

        // Push to private lists of listeners.
        this._listeners.push({
            name: name,
            fn: fn,
            ctx: ctx
        });

        return this;
    }
791857
function(listener) {
        // Check that listener has the required functions
        var events = ['comment', 'tag', 'feature', 'background', 'scenario', 'scenario_outline', 'examples', 'step', 'doc_string', 'row', 'eof'];
        for(e in events) {
          var event = events[e];
          if(typeof listener[event] != 'function') {
            "Error. No " + event + " function exists on " + JSON.stringify(listener);
          }
        }
        this.listener = listener;
      }
1217405
function Dispatcher(emitter, events) {
  if (!(this instanceof Dispatcher)) return new Dispatcher(emitter, events);

  assert(emitter instanceof EventEmitter, 'simple-dispatcher: emitter should be an EventEmitter');
  assert('object' == typeof events, 'simple-dispatcher: events should be an object');

  // iterate over keys in event
  // and map the cb values to the emitter.

  Object.keys(events).forEach(function(key) {
    var arr = Array.isArray(events[key]) ? events[key] : [events[key]];
    arr.forEach(function(cb) {
      emitter.on(key, cb);
    });
  });
}
652975
function addEventListener(event, listener) {
    this._eventListeners[event] = this._eventListeners[event] || [];
    this._eventListeners[event].push(listener);
  }
915287
function(listener) {
  // Check that listener has the required functions
  var events = ['comment', 'tag', 'feature', 'background', 'scenario', 'scenario_outline', 'examples', 'step', 'doc_string', 'row', 'eof'];
  for(var i=0, len=events.length; i<len; i++) {
    var event = events[i];
    if(typeof listener[event] != 'function') {
      throw new Error("Error. No " + event + " function exists on " + JSON.stringify(listener));
    }
  }
  this.listener = listener;
}
327986
function StreamHandler(host, port, delimiter) {
	events.EventEmitter.call(this);

	var self = this;
	self.delimiter = delimiter || "\r\n";
	self.host      = host;
	self.port      = port;

	self.buffer    = '';

	self.conn = net.createConnection(self.port, self.host);
	self.conn.setEncoding("utf8");

	self.conn.on('error', function(err) {
		try {
			self.emit('error', 'Stream error: ' + err, err);
		} catch (e) {
			console.log('' + err);
		}
	});
	self.conn.on('data', function(data) {
		self.conn.pause();
		self.buffer += data;
		if (self.buffer.match(/\n/)) {
			var arr = self.buffer.split(self.delimiter);
			//Everything except the last one
			for(var i = 0; i < arr.length - 1; i++) {
				self.emit('line', arr[i]);
			}
			self.buffer = arr[arr.length - 1];
		}
		if (self.conn.readyState == 'open') {
			self.conn.resume();
		}
	});
	self.conn.on('close', function(had_error) {
		if (!had_error && self.buffer.length > 0) {
			self.emit('line', self.buffer);
		}
	});
}
332976
function listener(message, sender) {
			var messageEvent = new MessageEvent({
				data: message,
				origin: sender.tab ? sender.tab.url : sender.url
			})
			if (
				('sourceChannel' in messageEvent)
				&& ('key' in messageEvent)
				&& transport.name === messageEvent.sourceChannel //events on the same channel
				&& transport.key !== messageEvent.key //skip returned back events
			) {
				handler(messageEvent)
			}
		}
1369125
function callListenersSequentially(i, args) {
    if (!this.events[eventName][i]) {
      // If there is no more listener to execute, we return a promise of the event arguments/result
      // So we are getting out of the recursive function
      return new Promise((resolve, reject) => {
        resolve(args);
      });
    }

    const p = Promise.resolve(this.events[eventName][i].apply(this.events[eventName][i], args));
    return p.then(function propagateArguments() {
      // We cannot use the "=>" notation here because we use `"arguments"
      // When an event listener has been executed, we move to the next one (recursivity)
      if (propagateResponses) {
        // Case the event must pass the result of a listener to the next one
        // This use case allow to transmit and alter primitive (strings, numbers ...)
        return callListenersSequentially.bind(this)(i + 1, arguments[0]);
      }
      // Case the event can pass the arguments to each listener
      // This use case allow a simple syntax for listener, compatible with fireConcurrently()
      // But it is not possible to transmit alterations made on primitive arguments
      return callListenersSequentially.bind(this)(i + 1, args);
    }.bind(this));
  }