{"size": 972, "ext": "js", "max_stars_repo_path": "util/TextMods.js", "max_stars_repo_name": "PvtTyphoon/Breezus", "max_stars_repo_stars_event_min_datetime": "2020-08-16T13:51:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-24T09:22:39.000Z", "max_issues_repo_path": "util/TextMods.js", "max_issues_repo_name": "PvtTyphoon/Breezus", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "util/TextMods.js", "max_forks_repo_name": "PvtTyphoon/Breezus", "max_forks_repo_forks_event_min_datetime": "2020-08-16T11:55:59.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-16T11:55:59.000Z"}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 33.5172413793, "max_line_length": 76, "alphanum_fraction": 0.5442386831}
module.exports = class Util {
  static delay(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }
  static shorten(text, maxLen) {
    return text.length > maxLen ? `${text.substr(0, maxLen - 3)}...` : text;
  }
  static base64(text, mode = "encode") {
    if (mode === "encode") return Buffer.from(text).toString("base64");
    if (mode === "decode")
      return Buffer.from(text, "base64").toString("utf8") || null;
    throw new TypeError(
      `The mode yoive selected, "${mode}" is not a supported base64 mode.`
    );
  }
  static cleanHTML(html) {
    let clean = html
      .replace(/(<br>)+/g, "\n")
      .replace(/&#39;/g, "'")
      .replace(/&quot;/g, '"')
      .replace(/<\/?i>/g, "*")
      .replace(/~!|!~/g, "||");
    if (clean.length > 2048) clean = `${clean.substr(0, 2045)}...`;
    const spoilers = (clean.match(/\|\|/g) || []).length;
    if (spoilers !== 0 && spoilers && spoilers % 2) clean += "||";
    return clean;
  }
};
