ну куча копипаста же:
```js
PubSub.prototype.subscribe = function(eventName, handler) {
    var handlers = this.events[eventName];

    if (!eventName ||
        !(handler instanceof Function) ||
        handlers.indexOf(handler) > -1
        ) {
        return handler;
    }
    
   if (!handlers) {
        handlers = this.events[eventName] = [];
    }

    handlers.push(handler); 
    return handler;
  };
```