<commit_before>export const capitalizeFirstLetter = str =>
  (str || '').charAt(0).toUpperCase() + (str || '').slice(1).toLowerCase();

export const isBetween = (num, min, max) => num >= min && num <= max;

export const coordinateKey = (x, y) => {
  const stringX = x - 1 < 10 ? `0${x - 1}` : `${x - 1}`;
  const stringY = y - 1 < 10 ? `0${y - 1}` : `${y - 1}`;
  return `${stringX}${stringY}`;
};

// Assumes x/y is less than 100
export const coordinatesFromKey = key => {
  if (!key) {
    return { x: null, y: null };
  }
  return {
    x: Number.parseInt(key.substring(0, 2), 10) + 1,
    y: Number.parseInt(key.substring(2, 4), 10) + 1,
  };
};

export const allSectorKeys = (width, height) => {
  const keys = [];
  for (let x = 1; x <= width; x += 1) {
    for (let y = 1; y <= height; y += 1) {
      keys.push(coordinateKey(x, y));
    }
  }
  return keys.sort();
};

export const stringSortByKey = key => (a, b) => {
  const keyA = (a[key] || '').toUpperCase();
  const keyB = (b[key] || '').toUpperCase();
  if (keyA < keyB) return -1;
  if (keyA > keyB) return 1;
  return 0;
};

export const toCommaArray = (element, i) => `${i !== 0 ? ', ' : ''}${element}`;<commit_msg>Default to zero for incoming parameters<commit_after>export const capitalizeFirstLetter = str =>
  (str || '').charAt(0).toUpperCase() + (str || '').slice(1).toLowerCase();

export const isBetween = (num, min, max) => num >= min && num <= max;

export const coordinateKey = (x, y) => {
  const stringX = x - 1 < 10 ? `0${x - 1}` : `${x - 1}`;
  const stringY = y - 1 < 10 ? `0${y - 1}` : `${y - 1}`;
  return `${stringX}${stringY}`;
};

// Assumes x/y is less than 100
export const coordinatesFromKey = key => {
  if (!key) {
    return { x: null, y: null };
  }
  return {
    x: Number.parseInt(key.substring(0, 2), 10) + 1,
    y: Number.parseInt(key.substring(2, 4), 10) + 1,
  };
};

export const allSectorKeys = (width = 0, height = 0) => {
  const keys = [];
  for (let x = 1; x <= width; x += 1) {
    for (let y = 1; y <= height; y += 1) {
      keys.push(coordinateKey(x, y));
    }
  }
  return keys.sort();
};

export const stringSortByKey = key => (a, b) => {
  const keyA = (a[key] || '').toUpperCase();
  const keyB = (b[key] || '').toUpperCase();
  if (keyA < keyB) return -1;
  if (keyA > keyB) return 1;
  return 0;
};

export const toCommaArray = (element, i) => `${i !== 0 ? ', ' : ''}${element}`;
{'fraction_non_alphanumeric': 0.22, 'fraction_numerical': 0.03, 'mean_word_length': 3.0150501672240804, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '2929117', 'n_tokens_mistral': 966, 'n_tokens_neox': 928, 'n_words': 270}