{"size": 718, "ext": "js", "max_stars_repo_path": "imports/api/posts/nameGen/generator.js", "max_stars_repo_name": "fangjj/ComfyCafe", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "imports/api/posts/nameGen/generator.js", "max_issues_repo_name": "fangjj/ComfyCafe", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "imports/api/posts/nameGen/generator.js", "max_forks_repo_name": "fangjj/ComfyCafe", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.9444444444, "max_line_length": 57, "alphanum_fraction": 0.6197771588}
import _ from "lodash";

import adjectives from "./adjectives";
import nouns from "./nouns";

function takeAdj(pool) {
  const adj = _.sample(adjectives);
  if (_.includes(pool, adj)) {
    return takeAdj(pool);
  } else {
    return adj;
  }
};

function generateName(options) {
  if (typeof options === "undefined") {
    options = {};
  }

  if (typeof options.delim === "undefined") {
    options.delim = "";
  }
  if (typeof options.adjCount === "undefined") {
    options.adjCount = 2;
  }

  let adjs = [];
  for (let i = 0; i < options.adjCount; ++i) {
    adjs.push(takeAdj(adjs));
  }
  const noun = _.sample(nouns);
  return adjs.join(options.delim) + options.delim + noun;
};

export default generateName;
