code: function createJsonEventData(eventId, event, metadata, type) {
    if (!event || typeof event !== 'object') throw new TypeError("data must be an object.");
  
    var eventBuf = new Buffer(JSON.stringify(event));
    var metaBuf = metadata ? new Buffer(JSON.stringify(metadata)) : null;
    return new EventData(eventId, type || event.constructor.name, true, eventBuf, metaBuf);
  }
docs: Create an EventData object from JavaScript event/metadata that will be serialized as json
  @public
  @param {string} eventId    Event UUID
  @param {object} event      Event object
  @param {object} [metadata] Event metadata
  @param {string} [type]     Event type
  @returns {EventData}