code: function aggregation(type, name) {
    if (utils.isObject(type)) {
      return type
    }
  
    if (!name) {
      throw new FieldError('Missing aggregation output name')
    }
    else if (!aggregations.hasOwnProperty(type)) {
      throw new FieldError('Unknown aggregation type: ' + type)
    }
  
    var args = utils.args(arguments, 2)
      , aggregation = {
        type: type,
        name: name
      }
  
    aggregations[type].apply(aggregation, args)
  
    return aggregation
  }
docs: Generate aggregation object
  
  @param {string|object} type Aggregation type or aggregation object
  @param {string} name Name of aggregated value
  @returns {object} Omg, it's aggregation JS object.