<commit_before>'use strict';

function trimLinebreaks(str) {
  // Remove leading and trailing linebreaks
  if (!str) {
    return str;
  }
  return str.replace(/^[\r\n]+|[\r\n]+$/g, '');
}

module.exports = {

  /* Parses additional KSS params for the styleguide */
  get: function(source) {

    // Remove comment markup from comments
    var comment = source.split('//').join('').split('/*').join('').split('*/').join(''),
      additionalKssParams = {};

    comment = trimLinebreaks(comment);

    comment.split('\n\n').forEach(function(markUpBlock) {

      var varName = markUpBlock.match(/([^:^\n]*):[\s\S]*\n/);
      if (varName && varName[1]) {
        varName = varName[1].trim();
      }
      if (varName && varName.substring(0, 3) === 'sg-') {
        additionalKssParams[varName] = markUpBlock.substring(markUpBlock.indexOf('\n') + 1);
      }

    });

    return additionalKssParams;
  }

};<commit_msg>Separate getting values for custom KSS parameters<commit_after>'use strict';

function trimLinebreaks(str) {
  // Remove leading and trailing linebreaks
  if (!str) {
    return str;
  }
  return str.replace(/^[\r\n]+|[\r\n]+$/g, '');
}

module.exports = {

  /* Parses additional KSS params for the styleguide */
  get: function(source) {

    // Remove comment markup from comments
    var comment = source.split('//').join('').split('/*').join('').split('*/').join(''),
      additionalKssParams = {},
      _this = this;

    comment = trimLinebreaks(comment);

    comment.split('\n\n').forEach(function(markUpBlock) {

      var varName = markUpBlock.match(/([^:^\n]*):[\s\S]*\n/);
      if (varName && varName[1]) {
        varName = varName[1].trim();
      }
      if (varName && varName.substring(0, 3) === 'sg-') {
        additionalKssParams[varName] = _this.getValue(markUpBlock);
      }

    });

    return additionalKssParams;
  },

  /* Parses values */
  getValue: function(str) {
    return str.substring(str.indexOf('\n') + 1);
  }

};
{'fraction_non_alphanumeric': 0.19635627530364372, 'fraction_numerical': 0.005060728744939271, 'mean_word_length': 2.954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6942995', 'n_tokens_mistral': 676, 'n_tokens_neox': 656, 'n_words': 124}