<commit_before>/* jshint browser: true */

function camelize(string) {
  return string.replace(/[_-](\w)/g, function (matched, letter) {
    return letter.toUpperCase()
  })
};


// the properties that we copy into a mirrored div
var properties = [
  'box-sizing',
  'border-width',
  'padding',
  'font',
  'letter-spacing',
  'word-spacing',
  'line-height',
  'text-transform',
  'text-indent',
  'text-decoration',  // might not make a difference, but better be safe
];

module.exports = function (textarea, position) {
  // mirrored div
  var div = document.createElement('div');
  document.body.appendChild(div);

  var style = div.style;
  var computed = getComputedStyle(textarea);

  style.position = 'absolute';
  style.whiteSpace = 'pre-wrap';
  style.wordWrap = 'break-word';
  style.bottom = style.left = '-9999px';
  style.overflow = 'hidden';
  style.width = computed.width;    // exclude the scrollbar, so the mirror div
  style.height = computed.height;  // ...wraps exactly as the textarea does

  // transfer textarea properties to the div
  properties.forEach(function (prop) {
    style[camelize(prop)] = computed.getPropertyValue(prop);
  });

  div.textContent = textarea.value.substring(0, position);

  var span = document.createElement('span');
  // Wrapping must be replicated *exactly*, including when a long word gets
  // onto the next line, with whitespace at the end of the line before (#7).
  // The  *only* reliable way to do that is to copy the *entire* rest of the
  // textarea's content into the <span> created at the caret position.
  span.textContent = textarea.value.substring(position);
  div.appendChild(span);

  var coordinates = {
    top: span.offsetTop + parseInt(computed.getPropertyValue('border-top-width')),
    left: span.offsetLeft + parseInt(computed.getPropertyValue('border-left-width')),
  };

  document.body.removeChild(div);

  return coordinates;
}<commit_msg>move camelize to the end<commit_after>/* jshint browser: true */

// the properties that we copy into a mirrored div
var properties = [
  'box-sizing',
  'border-width',
  'padding',
  'font',
  'letter-spacing',
  'word-spacing',
  'line-height',
  'text-transform',
  'text-indent',
  'text-decoration',  // might not make a difference, but better be safe
];

module.exports = function (textarea, position) {
  // mirrored div
  var div = document.createElement('div');
  document.body.appendChild(div);

  var style = div.style;
  var computed = getComputedStyle(textarea);

  style.position = 'absolute';
  style.whiteSpace = 'pre-wrap';
  style.wordWrap = 'break-word';
  style.bottom = style.left = '-9999px';
  style.overflow = 'hidden';
  style.width = computed.width;    // exclude the scrollbar, so the mirror div
  style.height = computed.height;  // ...wraps exactly as the textarea does

  // transfer textarea properties to the div
  properties.forEach(function (prop) {
    style[camelize(prop)] = computed.getPropertyValue(prop);
  });

  div.textContent = textarea.value.substring(0, position);

  var span = document.createElement('span');
  // Wrapping must be replicated *exactly*, including when a long word gets
  // onto the next line, with whitespace at the end of the line before (#7).
  // The  *only* reliable way to do that is to copy the *entire* rest of the
  // textarea's content into the <span> created at the caret position.
  span.textContent = textarea.value.substring(position);
  div.appendChild(span);

  var coordinates = {
    top: span.offsetTop + parseInt(computed.getPropertyValue('border-top-width')),
    left: span.offsetLeft + parseInt(computed.getPropertyValue('border-left-width')),
  };

  document.body.removeChild(div);

  return coordinates;
}

function camelize(string) {
  return string.replace(/[_-](\w)/g, function (matched, letter) {
    return letter.toUpperCase()
  })
}
{'fraction_non_alphanumeric': 0.13418115753957954, 'fraction_numerical': 0.003114456267843239, 'mean_word_length': 3.7935323383084576, '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': '2901468', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1156, 'n_words': 338}