'use strict';

var EventEmitter = require('events').EventEmitter;
var util = require('util');

function createBus() {
  var bus = new EventEmitter();

  bus.addListener = function addListener(handler) {
    return EventEmitter.prototype.addListener.call(this, 'event', handler);
  }

  bus.removeListener = function removeListener(handler) {
    return EventEmitter.prototype.removeListener.call(this, 'event', handler);
  }

  bus.emit = function emit(type, body) {
    var merged = util._extend({}, body);

    merged.type = type;

    return EventEmitter.prototype.emit.call(this, 'event', merged);
  }

  return bus;
}

module.exports = createBus;
