<commit_before>function l20nLoadFunc(localeFiles) {
  return new Promise((complete) => {
    const https = [];
    const makeRequest = url => new Promise((resolve, reject) => {
      const http = new XMLHttpRequest();

      http.open('GET', url, false);
      // http.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
      http.addEventListener('load', (response) => {
        resolve(response.target.response);
      });
      http.addEventListener('error', err => reject(err));
      http.addEventListener('abort', err => reject(err));
      http.send();
    });
    for (let i = 0; i < localeFiles.length; i += 1) {
      https.push(makeRequest(localeFiles[i]));
    }
    Promise.all(https).then((files) => {
      complete(files);
    });
  });
}

/**
 * Bootstrap localization
 * This function handles the bootstrapping of localization for
 * the application.
 */
export function bootstrapLocalization({
  supportedLocales,
  defaultLocale,
  currentLocale,
  localeFiles,
  asGlobal = false,
}) {
  const promise = new Promise((resolve) => {
    // The L20n context (ctx) should only call linkResource once per file.
    // We need to:
    //    * Strip out the locale from the path string (map)
    //    * Remove duplicates (reduce)
    //    * link each resource against a locale (forEach)
    localeFiles.map((path) => {
      let trimmed = path;
      supportedLocales.forEach((locale) => {
        trimmed = trimmed.replace(new RegExp(`/${locale}/`), '/');
      });<commit_msg>Prefer map vs loop<commit_after>function l20nLoadFunc(localeFiles) {
  return new Promise((complete) => {
    const makeRequest = url => new Promise((resolve, reject) => {
      const http = new XMLHttpRequest();

      http.open('GET', url, false);
      // http.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
      http.addEventListener('load', (response) => {
        resolve(response.target.response);
      });
      http.addEventListener('error', err => reject(err));
      http.addEventListener('abort', err => reject(err));
      http.send();
    });

    const https = localeFiles.map(file => makeRequest(file));
    Promise.all(https).then((files) => {
      complete(files);
    });
  });
}

/**
 * Bootstrap localization
 * This function handles the bootstrapping of localization for
 * the application.
 */
export function bootstrapLocalization({
  supportedLocales,
  defaultLocale,
  currentLocale,
  localeFiles,
  asGlobal = false,
}) {
  const promise = new Promise((resolve) => {
    // The L20n context (ctx) should only call linkResource once per file.
    // We need to:
    //    * Strip out the locale from the path string (map)
    //    * Remove duplicates (reduce)
    //    * link each resource against a locale (forEach)
    localeFiles.map((path) => {
      let trimmed = path;
      supportedLocales.forEach((locale) => {
        trimmed = trimmed.replace(new RegExp(`/${locale}/`), '/');
      });
{'fraction_non_alphanumeric': 0.14910199932226365, 'fraction_numerical': 0.004066418163334463, 'mean_word_length': 3.0327868852459017, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 24, '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': '2859921', 'n_tokens_mistral': 853, 'n_tokens_neox': 827, 'n_words': 216}