{"size": 709, "ext": "js", "max_stars_repo_path": "packages/search-ui/src/actions/setFilter.js", "max_stars_repo_name": "springload/search-ui", "max_stars_repo_stars_event_min_datetime": "2019-01-04T22:12:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T06:04:24.000Z", "max_issues_repo_path": "packages/search-ui/src/actions/setFilter.js", "max_issues_repo_name": "springload/search-ui", "max_issues_repo_issues_event_min_datetime": "2019-01-10T08:47:41.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:42:18.000Z", "max_forks_repo_path": "packages/search-ui/src/actions/setFilter.js", "max_forks_repo_name": "springload/search-ui", "max_forks_repo_forks_event_min_datetime": "2019-02-05T18:19:28.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-25T07:48:34.000Z"}
{"max_stars_count": 1653, "max_issues_count": 504, "max_forks_count": 324, "avg_line_length": 22.8709677419, "max_line_length": 78, "alphanum_fraction": 0.6149506347}
/**
 * Filter results - Replaces current filter value
 *
 * Will trigger new search
 *
 * @param name String field name to filter on
 * @param value FilterValue to apply
 * @param type String (Optional) type of filter to apply
 */
export default function setFilter(name, value, type = "all") {
  // eslint-disable-next-line no-console
  if (this.debug) console.log("Search UI: Action", "setFilter", ...arguments);

  let { filters } = this.state;
  filters = filters.filter(
    filter => filter.field !== name || filter.type !== type
  );

  this._updateSearchResults({
    current: 1,
    filters: [
      ...filters,
      {
        field: name,
        values: [value],
        type
      }
    ]
  });
}
