<commit_before>/* global BUILD_ID */

const getBulletUrl = color => `images/bullet_${color}.png?v=${BUILD_ID}`;

const getColor = lag =>
  (lag < 50 && "green") ||
  (lag < 100 && "yellow") ||
  (lag < 500 && "orange") ||
  (lag < 5000 && "red") ||
  "black";

const getIconUrl = lag => getBulletUrl(getColor(lag));

const getIconLinkElement = () => {
  let icon = document.querySelector("link[rel~=icon]");
  if (!icon) {
    icon = document.createElement("link");
    icon.rel = "icon";
    document.head.appendChild(icon);
  }
  icon.type = "image/png";
  return icon;
};

export default (user, pings) => {
  const iconElement = getIconLinkElement();
  user.events.on(
    "read",
    () => (iconElement.href = getIconUrl(pings.currentLag))
  );
};
<commit_msg>DocumentIcon to use class syntax<commit_after>/* global BUILD_ID */

const getBulletUrl = color => `images/bullet_${color}.png?v=${BUILD_ID}`;

const getColor = lag =>
  (lag < 50 && "green") ||
  (lag < 100 && "yellow") ||
  (lag < 500 && "orange") ||
  (lag < 5000 && "red") ||
  "black";

const getIconUrl = lag => getBulletUrl(getColor(lag));

const getIconLinkElement = () => {
  let icon = document.querySelector("link[rel~=icon]");
  if (!icon) {
    icon = document.createElement("link");
    icon.rel = "icon";
    document.head.appendChild(icon);
  }
  icon.type = "image/png";
  return icon;
};

export default class {
  constructor(user, pings) {
    const iconElement = getIconLinkElement();
    user.events.on(
      "read",
      () => (iconElement.href = getIconUrl(pings.currentLag))
    );
  }
}

{'fraction_non_alphanumeric': 0.1920152091254753, 'fraction_numerical': 0.015209125475285171, 'mean_word_length': 3.685459940652819, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '896279', 'n_tokens_mistral': 573, 'n_tokens_neox': 544, 'n_words': 113}