<commit_before>"use strict";

/**
 * @module Config
 */

/**
 * Retrieve sources from configuration files.
 *
 * @param {module:Spring~ConfigData} data - spring response data.
 * @return {Array<module:Spring~ConfigSource>} list of sources.
 */
function getSources(data) {
  return data.propertySources.map((file) => file.source);
}

/**
 * Configuration handler
 * @class
 */
class Config {
  /**
   * Function to apply to every property in configuration
   *
   * @callback forEachFunc
   * @param {string} key - property key
   * @param {*} value - property value
   */

  /**
   * Create config object.
   *
   * @param {module:Spring~ConfigData} data - spring response data
   */
  constructor(data) {
    this._raw = data;
    this._properties = getSources(this._raw).reduce((accum, value) => Object.assign({}, value, accum), {});
  }

  /**
   * Computed configuration properties
   *
   * @public
   * @type {module:Spring~ConfigSource}
   */
  get properties() {
    return Object.assign({}, this._properties);
  }


  /**
   * Raw spring response data
   *
   * @public
   * @type {module:Spring~ConfigData}
   */
  get raw() {
    return JSON.parse(JSON.stringify(this._raw));
  }

  /**
   * Retrieve a configuration property by key
   *
   * @public
   * @param {...string} keyParts - parts to join as key
   * @return {*} property value
   */
  get(keyParts) {
    const key = Array.prototype.slice.call(arguments).join('.');

    return this._properties[key];
  }

  /**
   * Iterate over configuration properties
   *
   * @public
   * @param {module:Config~forEachFunc} callback - function to apply to every property
   * @param {boolean} [includeOverridden=false] whether to include overridden properties
   */
  forEach(callback, includeOverridden) {
    const _include = includeOverridden || false;
    const sources = _include ? getSources(this._raw) : [this._properties];

    sources.forEach((source) => {
      for (let prop in source ) {
        if (source.hasOwnProperty(prop)) {
          callback(prop, source[prop]);
        }
      }
    });
  }

  /**
   * Returns a string representation of raw response data
   *
   * @public
   * @param {number} spaces - number spaces to use in formatting
   * @returns {string} - raw response data as string
   */
  toString(spaces) {
    return JSON.stringify(this._raw, null, spaces);
  }
}

module.exports = Config;
<commit_msg>Since annotations<commit_after>"use strict";

/**
 * @module Config
 */

/**
 * Retrieve sources from configuration files.
 *
 * @param {module:Spring~ConfigData} data - spring response data.
 * @return {Array<module:Spring~ConfigSource>} list of sources.
 */
function getSources(data) {
  return data.propertySources.map((file) => file.source);
}

/**
 * Configuration handler
 * @class
 */
class Config {
  /**
   * Function to apply to every property in configuration
   *
   * @callback forEachFunc
   * @param {string} key - property key
   * @param {*} value - property value
   */

  /**
   * Create config object.
   *
   * @param {module:Spring~ConfigData} data - spring response data
   */
  constructor(data) {
    this._raw = data;
    this._properties = getSources(this._raw).reduce((accum, value) => Object.assign({}, value, accum), {});
  }

  /**
   * Computed configuration properties
   *
   * @public
   * @type {module:Spring~ConfigSource}
   *
   * @since 1.0.0
   */
  get properties() {
    return Object.assign({}, this._properties);
  }


  /**
   * Raw spring response data
   *
   * @public
   * @type {module:Spring~ConfigData}
   *
   * @since 1.0.0
   */
  get raw() {
    return JSON.parse(JSON.stringify(this._raw));
  }

  /**
   * Retrieve a configuration property by key
   *
   * @public
   * @param {...string} keyParts - parts to join as key
   * @return {*} property value
   *
   * @since 1.0.0
   */
  get(keyParts) {
    const key = Array.prototype.slice.call(arguments).join('.');

    return this._properties[key];
  }

  /**
   * Iterate over configuration properties
   *
   * @public
   * @param {module:Config~forEachFunc} callback - function to apply to every property
   * @param {boolean} [includeOverridden=false] whether to include overridden properties
   *
   * @since 1.0.0
   */
  forEach(callback, includeOverridden) {
    const _include = includeOverridden || false;
    const sources = _include ? getSources(this._raw) : [this._properties];

    sources.forEach((source) => {
      for (let prop in source ) {
        if (source.hasOwnProperty(prop)) {
          callback(prop, source[prop]);
        }
      }
    });
  }

  /**
   * Returns a string representation of raw response data
   *
   * @public
   * @param {number} spaces - number spaces to use in formatting
   * @returns {string} - raw response data as string
   *
   * @since 1.0.0
   */
  toString(spaces) {
    return JSON.stringify(this._raw, null, spaces);
  }
}

module.exports = Config;

{'fraction_non_alphanumeric': 0.1380923327232052, 'fraction_numerical': 0.003050640634533252, 'mean_word_length': 2.824261275272162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '7097575', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1488, 'n_words': 387}