lib/fields/postAggregations.js
function postAggregation(type, name) {
  if (utils.isObject(type)) {
    return type
  }

  if (!name) {
    throw new FieldError('Missing post-aggregation name')
  }
  else if (!postAggregations.hasOwnProperty(type)) {
    throw new FieldError('Unknown post-aggregation type: ' + type)
  }

  var args = utils.args(arguments, 2)
    , postAggregation = {
      type: type,
      name: name
    }

  postAggregations[type].apply(postAggregation, args)

  return postAggregation
}
function postAggregation(type, name) {
  if (utils.isObject(type)) {
    return type
  }

  if (!name) {
    throw new FieldError('Missing post-aggregation name')
  }
  else if (!postAggregations.hasOwnProperty(type)) {
    throw new FieldError('Unknown post-aggregation type: ' + type)
  }

  var args = utils.args(arguments, 2)
    , postAggregation = {
      type: type,
      name: name
    }

  postAggregations[type].apply(postAggregation, args)

  return postAggregation
}
function postAggregation ( type , name ) { if ( utils . isObject ( type ) ) { return type } if ( ! name ) { throw new FieldError ( 'Missing post-aggregation name' ) } else if ( ! postAggregations . hasOwnProperty ( type ) ) { throw new FieldError ( 'Unknown post-aggregation type: ' + type ) } var args = utils . args ( arguments , 2 ) , postAggregation = { type : type , name : name } postAggregations [ type ] . apply ( postAggregation , args ) return postAggregation }
Generate post-aggregation object

@param {string|object} type Post-aggregation type or post-aggregation object
@param {string} name Name of aggregated value
@returns {object} Dude, you know? It's a post-aggregation thing!
Generate post - aggregation object