<commit_before>/* global XMLHttpRequest */
function webRequest (url) {
  return new Promise((resolve, reject) => {
    var xhr = new XMLHttpRequest()
    xhr.open('GET', url, true)
    xhr.onload = function () {
      if (xhr.status >= 200 && xhr.status < 300) {
        resolve(xhr.responseText)
      } else {
        reject(new Error(xhr.statusText + ' ' + url))
      }
    }
    xhr.onerror = function () {
      reject(new Error(xhr.statusText))
    }
    xhr.send(null)
  })
}

function jsonWebRequest (url) {
  return new Promise((resolve, reject) => {
    webRequest(url).then(function (response) {
      var json = JSON.parse(response)
      resolve(json)
    }).catch(reject)
  })
}

module.exports = {
  webRequest: webRequest,
  jsonWebRequest: jsonWebRequest
}
<commit_msg>added random id generator<commit_after>/* global XMLHttpRequest */
function webRequest (url) {
  return new Promise((resolve, reject) => {
    var xhr = new XMLHttpRequest()
    xhr.open('GET', url, true)
    xhr.onload = function () {
      if (xhr.status >= 200 && xhr.status < 300) {
        resolve(xhr.responseText)
      } else {
        reject(new Error(xhr.statusText + ' ' + url))
      }
    }
    xhr.onerror = function () {
      reject(new Error(xhr.statusText))
    }
    xhr.send(null)
  })
}

function jsonWebRequest (url) {
  return new Promise((resolve, reject) => {
    webRequest(url).then(function (response) {
      var json = JSON.parse(response)
      resolve(json)
    }).catch(reject)
  })
}
function randomId () {
  var id = ''
  var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'

  for (var i = 0; i < 8; i++) { id += possible.charAt(Math.floor(Math.random() * possible.length)) }

  return id
}

module.exports = {
  webRequest: webRequest,
  jsonWebRequest: jsonWebRequest,
  getRandomId: randomId
}

{'fraction_non_alphanumeric': 0.1413102328099621, 'fraction_numerical': 0.012994044396318355, 'mean_word_length': 2.9741935483870967, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '3999195', 'n_tokens_mistral': 650, 'n_tokens_neox': 623, 'n_words': 130}