{"size": 802, "ext": "js", "max_stars_repo_path": "src/js/metric.js", "max_stars_repo_name": "thehassantahir/httparchive.org", "max_stars_repo_stars_event_min_datetime": "2018-03-28T23:15:08.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T19:46:18.000Z", "max_issues_repo_path": "src/js/metric.js", "max_issues_repo_name": "samdutton/httparchive.org", "max_issues_repo_issues_event_min_datetime": "2018-03-27T18:12:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-16T16:57:27.000Z", "max_forks_repo_path": "src/js/metric.js", "max_forks_repo_name": "samdutton/httparchive.org", "max_forks_repo_forks_event_min_datetime": "2018-07-10T12:09:48.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T21:16:03.000Z"}
{"max_stars_count": 269, "max_issues_count": 238, "max_forks_count": 47, "avg_line_length": 29.7037037037, "max_line_length": 88, "alphanum_fraction": 0.6408977556}
export class Metric {
  constructor(options, value=null) {
    this.options = options;

    if (wholeNumber.has(options.type)) {
      value = Math.round(value);
    }
    this.value = value;
  }

  toString() {
    let type = this.options.type;
    if (this.options.singular && this.value === 1) {
      type = this.options.singular;
    }
    return `${this.value}${noLeadingSpace.has(type) ? '' : ' '}${type}`;
  }
}

// Whitelist of units that directly follow the value (eg "10%").
// Otherwise, the unit is preceded by a space (eg "10 KB").
const noLeadingSpace = new Set(['%']);

// Whitelist of units for which values should appear as whole numbers (eg "2 requests").
// Otherwise, the values would appear as floats (eg "2.0 requests").
const wholeNumber = new Set(['Connections', 'Requests']);
