<commit_before>/*
 * grunt-set-app-mode
 * https://github.com/cfogelberg/grunt-set-app-mode
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

var ModeGroupConfig = require("../lib/mode_group_config");

function ModeGroupConfigCollection (files_array, expected_modes) {
  this.configs = [];

  if(files_array.length === 0) {
    throw new Error("Cannot create ModeGroupConfigCollection with an empty files array");
  }

  for(var i = 0; i < files_array.length; ++i) {
    this.configs.push(new ModeGroupConfig(files_array[i].orig, expected_modes));
  }
};

ModeGroupConfigCollection.prototype.length = function() {
  return this.configs.length;
};

ModeGroupConfigCollection.prototype.get = function(index) {
  return this.configs[index];
};

module.exports = ModeGroupConfigCollection;
<commit_msg>ModeGroupConfigCollection - better error messages for badly formatted input mode group objects array<commit_after>/*
 * grunt-set-app-mode
 * https://github.com/cfogelberg/grunt-set-app-mode
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

var ModeGroupConfig = require("../lib/mode_group_config");

function ModeGroupConfigCollection (files_array, expected_modes) {
  this.configs = [];

  if(files_array.length === 0) {
    throw new Error("Cannot create ModeGroupConfigCollection with an empty files array");
  }

  for(var i = 0; i < files_array.length; ++i) {
    if(!files_array[i].orig) {
      throw new Error("Falsey (undefined?) 'orig' field - mode group config data bad format?")
    }
    this.configs.push(new ModeGroupConfig(files_array[i].orig, expected_modes));
  }
};

ModeGroupConfigCollection.prototype.length = function() {
  return this.configs.length;
};

ModeGroupConfigCollection.prototype.get = function(index) {
  return this.configs[index];
};

module.exports = ModeGroupConfigCollection;

{'fraction_non_alphanumeric': 0.1301775147928994, 'fraction_numerical': 0.006455083378160301, 'mean_word_length': 4.602409638554217, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '911531', 'n_tokens_mistral': 591, 'n_tokens_neox': 567, 'n_words': 126}