{"size": 831, "ext": "js", "max_stars_repo_path": "src/helpers/classnames.js", "max_stars_repo_name": "meridianid/surel", "max_stars_repo_stars_event_min_datetime": "2018-07-27T16:44:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-11T03:16:50.000Z", "max_issues_repo_path": "src/helpers/classnames.js", "max_issues_repo_name": "meridianid/surel", "max_issues_repo_issues_event_min_datetime": "2018-10-10T15:51:59.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-04T11:34:38.000Z", "max_forks_repo_path": "src/helpers/classnames.js", "max_forks_repo_name": "meridianid/surel", "max_forks_repo_forks_event_min_datetime": "2018-07-29T16:30:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-29T08:29:19.000Z"}
{"max_stars_count": 42, "max_issues_count": 3, "max_forks_count": 11, "avg_line_length": 28.6551724138, "max_line_length": 89, "alphanum_fraction": 0.59566787}
/**
 * Conditionally output class names based on a hash of arguments.
 */
module.exports = (...args) => {
  // If the first argument is a string, it's used as the base for a BEM modifier
  const [baseClass] = args;
  const classPrefix = typeof baseClass === 'string' ? `${baseClass}--` : '';

  return args.reduce((classes, arg) => {
    // String arguments are static classes
    if (typeof arg === 'string') {
      return classes.concat([arg]);
    }

    // The Handlebars context argument contains an object of each named parameter passed
    if (arg.hash) {
      return classes.concat(Object.entries(arg.hash).reduce((list, [cls, condition]) => {
        if (condition) {
          return list.concat([`${classPrefix}${cls}`]);
        }

        return list;
      }, []));
    }

    return classes;
  }, []).join(' ');
}
