src/lib/base/eventemitter3.js
function addListener(emitter, event, fn, context, once) {
  if (typeof fn !== 'function') {
    throw new TypeError('The listener must be a function');
  }

  var listener = new EE(fn, context || emitter, once)
    , evt = prefix ? prefix + event : event;

  if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  else emitter._events[evt] = [emitter._events[evt], listener];

  return emitter;
}
function addListener(emitter, event, fn, context, once) {
  if (typeof fn !== 'function') {
    throw new TypeError('The listener must be a function');
  }

  var listener = new EE(fn, context || emitter, once)
    , evt = prefix ? prefix + event : event;

  if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  else emitter._events[evt] = [emitter._events[evt], listener];

  return emitter;
}
function addListener ( emitter , event , fn , context , once ) { if ( typeof fn !== 'function' ) { throw new TypeError ( 'The listener must be a function' ) ; } var listener = new EE ( fn , context || emitter , once ) , evt = prefix ? prefix + event : event ; if ( ! emitter . _events [ evt ] ) emitter . _events [ evt ] = listener , emitter . _eventsCount ++ ; else if ( ! emitter . _events [ evt ] . fn ) emitter . _events [ evt ] . push ( listener ) ; else emitter . _events [ evt ] = [ emitter . _events [ evt ] , listener ] ; return emitter ; }
Add a listener for a given event.

@param {EventEmitter} emitter Reference to the `EventEmitter` instance.
@param {(string|Symbol)} event The event name.
@param {Function} fn The listener function.
@param {*} context The context to invoke the listener with.
@param {boolean} once Specify if the listener is a one-time listener.
@returns {EventEmitter}
@private
Add a listener for a given event .