{"size": 651, "ext": "js", "max_stars_repo_path": "lib/fields/filter.js", "max_stars_repo_name": "neuro-sys/node-druid-query", "max_stars_repo_stars_event_min_datetime": "2015-01-07T02:16:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-13T23:27:15.000Z", "max_issues_repo_path": "lib/fields/filter.js", "max_issues_repo_name": "neuro-sys/node-druid-query", "max_issues_repo_issues_event_min_datetime": "2015-05-14T20:19:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-17T13:25:38.000Z", "max_forks_repo_path": "lib/fields/filter.js", "max_forks_repo_name": "bringg/node-druid-query", "max_forks_repo_forks_event_min_datetime": "2015-02-03T09:07:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-21T03:51:10.000Z"}
{"max_stars_count": 93, "max_issues_count": 28, "max_forks_count": 36, "avg_line_length": 18.6, "max_line_length": 65, "alphanum_fraction": 0.6466973886}
'use strict'

var FieldError = require('../errors').FieldError
  , utils = require('./../utils')
  , filters = utils.moduleMap(__dirname + '/filters')

module.exports = filter




/**
 * Generate query filter object
 *
 * @param {string|object} type Filter type or ready filter object
 * @returns {object} Brand new ready to use filter!
 */
function filter(type) {
  if (utils.isObject(type)) {
    return type
  }
  else if (!filters.hasOwnProperty(type)) {
    throw new FieldError('Bad filter type: ' + type)
  }

  var args = utils.args(arguments, 1)
    , filter = {
      type: type
    }

  filters[type].apply(filter, args)

  return filter
}
