<commit_before>// tslint:disable: no-null-keyword
export async function asyncRequest<T> (
  type: string, dest: string, body: {} | null = null, bodyType: string = 'application/json'
): Promise<T> {
  const xhr = new XMLHttpRequest()
  xhr.open(type, dest, true)
  xhr.setRequestHeader('Accept', 'application/json')
  const res = new Promise<T>((resolve, reject) => {
    xhr.onreadystatechange = (e) => {
      if (xhr.readyState === 4) {
        if (xhr.status === 204 || xhr.status === 205) {
          resolve()
        } else if (xhr.status >= 200 && xhr.status < 300) {
          resolve(JSON.parse(xhr.responseText))
        } else {
          reject(JSON.parse(xhr.responseText))
        }
      }
    }
    if (body != null && bodyType === 'application/json') {
      xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
      xhr.send(JSON.stringify(body))
    } else if (body != null) {
      xhr.setRequestHeader('Content-Type', 'application/octet-stream')
      xhr.send(body)
    } else {
      xhr.send(null)
    }
  })
  return res
}<commit_msg>[Client] Respect bodyType<commit_after>// tslint:disable: no-null-keyword
export async function asyncRequest<T> (
  type: string, dest: string, body: {} | null = null, bodyType: string = 'application/json'
): Promise<T> {
  const xhr = new XMLHttpRequest()
  xhr.open(type, dest, true)
  xhr.setRequestHeader('Accept', 'application/json')
  const res = new Promise<T>((resolve, reject) => {
    xhr.onreadystatechange = (e) => {
      if (xhr.readyState === 4) {
        if (xhr.status === 204 || xhr.status === 205) {
          resolve()
        } else if (xhr.status >= 200 && xhr.status < 300) {
          resolve(JSON.parse(xhr.responseText))
        } else {
          reject(JSON.parse(xhr.responseText))
        }
      }
    }
    if (body != null && bodyType === 'application/json') {
      xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
      xhr.send(JSON.stringify(body))
    } else if (body != null) {
      xhr.setRequestHeader('Content-Type', bodyType)
      xhr.send(body)
    } else {
      xhr.send(null)
    }
  })
  return res
}
{'fraction_non_alphanumeric': 0.16372093023255813, 'fraction_numerical': 0.013023255813953489, 'mean_word_length': 2.76707530647986, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1173457', 'n_tokens_mistral': 746, 'n_tokens_neox': 713, 'n_words': 144}