text: // @ts-check
  
  /**
   * @module pubsub
   */
  
  /**
   * @return {Object}
   */
  
  const events = {};
  
  /**
   * Subscribe to an event
   * @param {string} eventName - Name of the event
   * @param {Function} fn - Function to be called
   */
  const subscribe = function (eventName, fn) {
    events[eventName] = events[eventName] || [];
    events[eventName].push(fn);
  };
  
  /**
   * Unsuscribe from an event
   * @param {string} eventName - Name of the event
   * @param {Function} fn - Function to be removed
   */
  const unsubscribe = function (eventName, fn) {
    if (events[eventName]) {
      for (let i = 0; i < events[eventName].length; i++) {
        if (events[eventName][i] === fn) {
          events[eventName].splice(i, 1);
          break;
        }
      }
    }
  };
  
  /**
   * Publish an event
   * @param {string} eventName - Name of the event
   * @param {*} data -data to be passed into callback
   */
  const publish = function (eventName, ...data) {
    if (events[eventName]) {
      events[eventName].forEach(function (fn) {
        fn(data[0], data[1], data[2], data[3]);
      });
    }
  };
  
  export { publish, unsubscribe, subscribe };
  