<commit_before>$(function () {

  var setText = function (textarea, text) {
    var range;
    textarea.focus();
    if (typeof textarea.selectionStart === 'number') {
      textarea.value = text;
      textarea.selectionStart = textarea.selectionEnd = 3;
      return;
    }
    range = textarea.createTextRange();
    range.text = text
    range.select();
  }

  var $textarea = $('textarea').textcomplete({
    // emoji strategy
    emoji: {
      match: /(^|\s):([\-+\w]*)$/,
      search: function (term, callback) {
        var regexp = new RegExp('^' + term.replace(/\+/g, '\\+'));
        callback($.map(emojies, function (emoji) {
          return regexp.test(emoji) ? emoji : null;
        }));
      },
      template: function (value) {
        return '<img src="media/images/emoji/' + value + '.png"></img>' + value;
      },
      replace: function (value) {
        return '$1:' + value + ': ';
      },
      maxCount: 5
    }
  });

  setText($textarea.get(0), ':a');
  $textarea.keyup();
});<commit_msg>Use `String.prototype.startsWith` method instead of the regular expression<commit_after>$(function () {

  var setText = function (textarea, text) {
    var range;
    textarea.focus();
    if (typeof textarea.selectionStart === 'number') {
      textarea.value = text;
      textarea.selectionStart = textarea.selectionEnd = 3;
      return;
    }
    range = textarea.createTextRange();
    range.text = text
    range.select();
  }

  var startsWith = String.prototype.startsWith || function (str, position) {
    position = position || 0;
    return ('' + this).indexOf(str, position) === position;
  };

  var $textarea = $('textarea').textcomplete({
    // emoji strategy
    emoji: {
      match: /(^|\s):([\-+\w]*)$/,
      search: function (term, callback) {
        callback($.map(emojies, function (emoji) {
          return startsWith.call(emoji, term) ? emoji : null;
        }));
      },
      template: function (value) {
        return '<img src="media/images/emoji/' + value + '.png"></img>' + value;
      },
      replace: function (value) {
        return '$1:' + value + ': ';
      },
      maxCount: 5
    }
  });

  setText($textarea.get(0), ':a');
  $textarea.keyup();
});
{'fraction_non_alphanumeric': 0.1811626858945471, 'fraction_numerical': 0.00405588102748986, 'mean_word_length': 2.441860465116279, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5276204', 'n_tokens_mistral': 719, 'n_tokens_neox': 691, 'n_words': 152}