<commit_before>
angular.module('average-app', [])

.factory('average', function() {
  return function average(values) {
    
    // Check if values is an array
    if ( Object.prototype.toString.apply(values) !== '[object Array]' ) {
      throw new Error('invalid parameter `values`');
    }
    
    // Check if it is empty
    var count = values.length;
    if ( count === 0 ) {
      return 0;
    }
    
    // Calculate average
    var sum = 0;
    for(var index=0; index < count; index++) {
      sum = sum + values[index];
    }
    return sum / count;
    
  };
});<commit_msg>refact(average-service): use angular.isArray<commit_after>
angular.module('average-app', [])

.factory('average', function() {

  return function average(values) {

    if ( !angular.isArray(values) ) {
      throw new Error('invalid parameter `values`');
    }

    // Check if it is empty
    var count = values.length;
    if ( count === 0 ) {
      return 0;
    }

    // Calculate average
    var sum = 0;
    for(var index=0; index < count; index++) {
      sum = sum + values[index];
    }
    return sum / count;

  };
});
{'fraction_non_alphanumeric': 0.1512981199641898, 'fraction_numerical': 0.007162041181736795, 'mean_word_length': 2.3473053892215567, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2448445', 'n_tokens_mistral': 361, 'n_tokens_neox': 343, 'n_words': 96}