<commit_before>"use strict";

export const domReady = new Promise(resolve => {
  function checkState() {
    if (document.readyState != 'loading') resolve();
  }
  document.addEventListener('readystatechange', checkState);
  checkState();
});

const range = document.createRange();
range.selectNode(document.documentElement);

export function strToEl(str) {
  const frag = range.createContextualFragment(str);
  return frag.children[0];
}

const entityMap = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': '&quot;',
  "'": '&#39;',
  "/": '&#x2F;'
};

export function escapeHTML(string) {
  return String(str).replace(/[&<>"'\/]/g, s => entityMap[s]);
}

export function escapeHtmlTag(strings, ...values) {
  values = values.map(s => escapeHTML(s));
  return strings.reduce((str, val, i) => str += val + (values[i] || ''), '');
};

export function readFileAsText(file) {
  return new Response(file).text();
};

export function handleFileInput(files) {
  const filesArray = Array.from(files);
  return Promise.all(<commit_msg>Fix possible typo in utils.js<commit_after>"use strict";

export const domReady = new Promise(resolve => {
  function checkState() {
    if (document.readyState != 'loading') resolve();
  }
  document.addEventListener('readystatechange', checkState);
  checkState();
});

const range = document.createRange();
range.selectNode(document.documentElement);

export function strToEl(str) {
  const frag = range.createContextualFragment(str);
  return frag.children[0];
}

const entityMap = {
  "&": "&amp;",
  "<": "&lt;",
  ">": "&gt;",
  '"': '&quot;',
  "'": '&#39;',
  "/": '&#x2F;'
};

export function escapeHTML(str) {
  return String(str).replace(/[&<>"'\/]/g, s => entityMap[s]);
}

export function escapeHtmlTag(strings, ...values) {
  values = values.map(s => escapeHTML(s));
  return strings.reduce((str, val, i) => str += val + (values[i] || ''), '');
};

export function readFileAsText(file) {
  return new Response(file).text();
};

export function handleFileInput(files) {
  const filesArray = Array.from(files);
  return Promise.all(
{'fraction_non_alphanumeric': 0.20173326913818007, 'fraction_numerical': 0.0038517091959557053, 'mean_word_length': 4.804469273743017, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 15, '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': '1264915', 'n_tokens_mistral': 696, 'n_tokens_neox': 691, 'n_words': 145}