code: function wrap() {
    var ports = this.compiledModule.ports;
  
    var incomingEmitter = new EventEmitter();
    var outgoingEmitter = new EventEmitter();
  
    var emit = incomingEmitter.emit.bind(incomingEmitter);
  
    Object.keys(ports).forEach(function(key) {
      outgoingEmitter.addListener(key, function() {
        var args = Array.prototype.slice.call(arguments)
  
        ports[key].send.apply(ports[key], args);
      });
  
      if (ports[key].subscribe) {
        ports[key].subscribe(function() {
          var args = Array.prototype.slice.call(arguments);
          args.unshift(key);
  
          emit.apply(incomingEmitter, args);
        });
      }
    });
  
    incomingEmitter.emit = outgoingEmitter.emit.bind(outgoingEmitter);;
  
    this.emitter = incomingEmitter;
    this.ports = this.compiledModule.ports;
  }
docs: wrap compiled and executed object in EventEmitters