(function() {
  var EE,
    slice = [].slice;

  EE = require("events");

  module.exports = function(aProcess) {
    var emitter;
    emitter = new EE();
    aProcess.on("message", function(message) {
      return emitter.emit.apply(emitter, [message.event].concat(slice.call(message.args)));
    });
    return {
      send: function() {
        var args, event;
        event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
        if (aProcess.killed) {
          return;
        }
        return aProcess.send({
          event: event,
          args: args
        });
      },
      on: emitter.on.bind(emitter),
      removeListener: emitter.removeListener.bind(emitter)
    };
  };

}).call(this);
