<commit_before>
MeteorSettings = { REQUIRED: 1 };

_.extend( MeteorSettings, {

  setDefaults: function (defaultsMap, options) {

    if (options === MeteorSettings.REQUIRED) {

      if (! Meteor.settings /* undefined on client */ ||
          _.size(Meteor.settings) === 0 /* empty on server */ ) {

        throw new Meteor.Error("settings-required", "--settings or METEOR_SETTINGS required.");
        // Note: it might also be the case that `settings.json` is empty... but it's unlikely.
      }
    }

    Meteor.settings = Meteor.settings || {};
    Meteor.settings.public = Meteor.settings.public || {};

    _deepDefaults(Meteor.settings, defaultsMap);
  }
});

var _nodes;

var _deepDefaults = function (settings, map) {
  _nodes = [];
  return __deepDefaults(settings, map);
}

var __deepDefaults = function (settings, node) {

  _.each(node, function (node, key) {

    // watch for circular reference
    if (_.indexOf(_nodes, node) >= 0) {
      throw new Meteor.Error("circular-defaults", "Circular reference found at: " + node.toString());
    }
    _nodes.push(node);

    // deep defaults
    if ((node instanceof Object) &&
      ! (node instanceof Date) &&
      ! (node.constructor === Array)) {

      settings[key] = settings[key] || {};

      __deepDefaults(settings[key], node);
    }
    else {
      settings[key] = settings[key] || node;
    }
  });
}
<commit_msg>Better circular-defaults message<commit_after>
MeteorSettings = { REQUIRED: 1 };

_.extend( MeteorSettings, {

  setDefaults: function (defaultsMap, options) {

    if (options === MeteorSettings.REQUIRED) {

      if (! Meteor.settings /* undefined on client */ ||
          _.size(Meteor.settings) === 0 /* empty on server */ ) {

        throw new Meteor.Error("settings-required", "--settings or METEOR_SETTINGS required.");
        // Note: it might also be the case that `settings.json` is empty... but it's unlikely.
      }
    }

    Meteor.settings = Meteor.settings || {};
    Meteor.settings.public = Meteor.settings.public || {};

    _deepDefaults(Meteor.settings, defaultsMap);
  }
});

var _nodes;

var _deepDefaults = function (settings, map) {
  _nodes = [];
  return __deepDefaults(settings, map);
}

var __deepDefaults = function (settings, node) {

  _.each(node, function (node, key) {

    // watch for circular reference
    if (_.indexOf(_nodes, node) >= 0) {
      throw new Meteor.Error("circular-defaults",
        "Circular reference found at: " + key + ":" + node);
    }
    _nodes.push(node);

    // deep defaults
    if ((node instanceof Object) &&
      ! (node instanceof Date) &&
      ! (node.constructor === Array)) {

      settings[key] = settings[key] || {};

      __deepDefaults(settings[key], node);
    }
    else {
      settings[key] = settings[key] || node;
    }
  });
}

{'fraction_non_alphanumeric': 0.1496090973702914, 'fraction_numerical': 0.0021321961620469083, 'mean_word_length': 2.8299319727891157, 'pattern_counts': {'":': 1, '<': 3, '<?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': '1949264', 'n_tokens_mistral': 903, 'n_tokens_neox': 835, 'n_words': 215}