<commit_before>import 'whatwg-fetch';

var helpers = {
  checkStatus,
  displayPrice,
  parseJSON,
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  }
};

function checkStatus(res) {
  if (res.status >= 200 && res.status < 300) {
    return res;
  } else {
    var error = new Error(res.statusText);
    error.res = res;
    throw error;
  }
}

function displayPrice(price) {
  if (typeof price === 'string') {
    price = Number(price);
  }

  if (price % 1 === 0) {
    return '$' + price;
  } else {
    return '$' + price.toFixed(2);
  }
}

function parseJSON(res) {
  return res.json();
}

export default helpers;<commit_msg>Add findTypeName, findTypeId, and capitalize functions<commit_after>import 'whatwg-fetch';
import _ from 'underscore';

var helpers = {
  capitalize,
  checkStatus,
  displayPrice,
  findTypeId,
  findTypeName,
  parseJSON,
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  }
};

function capitalize(string) {
  if (string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  }
}

function checkStatus(res) {
  if (res.status >= 200 && res.status < 300) {
    return res;
  } else {
    var error = new Error(res.statusText);
    error.res = res;
    throw error;
  }
}

function displayPrice(price) {
  if (typeof price === 'string') {
    price = Number(price);
  }

  if (price % 1 === 0) {
    return '$' + price;
  } else {
    return '$' + price.toFixed(2);
  }
}

function findTypeId(types, name) {
  let type = _.findWhere(types, { name: name });
  return type && type.id;
}

function findTypeName(types, id) {
  let type = _.findWhere(types, { id: id });
  return type && type.name;
}

function parseJSON(res) {
  return res.json();
}

export default helpers;
{'fraction_non_alphanumeric': 0.15500839395635144, 'fraction_numerical': 0.01119194180190263, 'mean_word_length': 3.2070588235294117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5285491', 'n_tokens_mistral': 647, 'n_tokens_neox': 624, 'n_words': 147}