<commit_before>
import Format from "../format";
import Validate from "../validate";
import defaultRegex from "./defaults";

const Regex = {};

Regex.addRegex = (name, test, validate) => {
  if (Regex[name]) {
    throw new Error(
      "Regex assigned",
      `Regex ${name} is already registered`
    );
  }

  if (!test || !(test instanceof RegExp)) {
    throw new Error(
      "Regex TypeError",
      `Regexter ${name} requires a regex`
    );
  }

  Regex[name] = test;

  if (validate) {
    const funcName = `is${Format.capitalize(name)}`;
    Validate.addValidator(funcName, str => (test.test(str)));
  }
  return;
};

/*

  Defualt regexes

*/
// such a long regex
<commit_msg>lint util regex index<commit_after>
import Format from "../format";
import Validate from "../validate";
import defaultRegex from "./defaults";

const Regex = {};

Regex.addRegex = (name, test, validate) => {
  if (Regex[name]) {
    throw new Error(
      "Regex assigned",
      `Regex ${name} is already registered`
    );
  }

  if (!test || !(test instanceof RegExp)) {
    throw new Error(
      "Regex TypeError",
      `Regexter ${name} requires a regex`
    );
  }

  Regex[name] = test;

  if (validate) {
    const funcName = `is${Format.capitalize(name)}`;
    Validate.addValidator(funcName, str => (test.test(str)));
  }
  return;
};

/*

  Defualt regexes

*/
// such a long regex

// eslint-disable-next-line
{'fraction_non_alphanumeric': 0.1595744680851064, 'fraction_numerical': 0.0, 'mean_word_length': 2.9303621169916436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '488936', 'n_tokens_mistral': 460, 'n_tokens_neox': 453, 'n_words': 130}