docs: function addTypeListener(emitter, type, event, listener) {
      if (!emitter._listeners) {
          emitter._listeners = {
              on: {},
              after: {},
              before: {}
          };
      }
  
      if (!emitter._listeners[type][event]) {
          emitter._listeners[type][event] = [];
      }
      if ('on' == type && emitter._listeners[type][event].length) {
          throw Error('Listener for event "' + event + '" already defined.');
      }
  
      emitter._listeners[type][event].push(listener);
  
      return function remove() {
          const index = emitter._listeners[type][event].indexOf(listener);
          if (-1 !== index) {
              emitter._listeners[type][event].splice(index, 1);
          }
      };
  }