<commit_before>/**

  config-editor.js

  Helper functions to edit the sneakers.json file.

**/


//
//  Dependencies
//

var _ = require("lodash"),
    fs = require("fs"),
    path = require("path");


var editor = module.exports = {

  config: null,

  defaults: require("../server/defaults.js"),

  filename: path.join(process.cwd(), "sneakers.json"),


  /**

    Loads and caches the config file

  **/

  load: function() {

    if (editor.config) return editor.config;

    try {
      editor.config = fs.readFileSync(editor.filename, "utf8");
    } catch (err) {
      editor.config = Object.assign({}, editor.defaults);
    }

    // We don't want this in the try/catch loop as it could overwrite custom
    // configuration files
    if ("string" === typeof editor.config)
      editor.config = JSON.parse(editor.config);

    return editor.config;

  },


  /**

    Loads defaults but does not write

  **/

  loadDefaults: function() {
    editor.config = editor.defaults;
  },


  /**

    Get a key from the config file.

    @param {String} key The key to lookup (supports dot-notation)
    @returns {*} The value of the key

  **/

  get: function(key) {
    return _.get(editor.load(), key);
  },


  /**

    Sets a key in the config file.

    @param {String} key The path of the property to set (supports dot-notation)
    @param {*} val The value to set

  **/

  set: function(key, val) {
    _.set(editor.load(), key, val);
  },


  /**

    Removes the property in the config.

    @param {String} key The path of the property to unset (supports dot-notation)

  **/

  unset: function(key) {
    _.unset(editor.load(), key);
  },


  /**

    Saves the config.

  **/

  save: function() {
    fs.writeFileSync(editor.filename, JSON.stringify(editor.load(), null, 2), "utf8");
  }

};
<commit_msg>config-editor#remove: new function<commit_after>/**

  config-editor.js

  Helper functions to edit the sneakers.json file.

**/


//
//  Dependencies
//

var _ = require("lodash"),
    fs = require("fs"),
    path = require("path");


var editor = module.exports = {

  config: null,

  defaults: require("../server/defaults.js"),

  filename: path.join(process.cwd(), "sneakers.json"),


  /**

    Loads and caches the config file

  **/

  load: function() {

    if (editor.config) return editor.config;

    try {
      editor.config = fs.readFileSync(editor.filename, "utf8");
    } catch (err) {
      editor.config = Object.assign({}, editor.defaults);
    }

    // We don't want this in the try/catch loop as it could overwrite custom
    // configuration files
    if ("string" === typeof editor.config)
      editor.config = JSON.parse(editor.config);

    return editor.config;

  },


  /**

    Loads defaults but does not write

  **/

  loadDefaults: function() {
    editor.config = editor.defaults;
  },


  /**

    Get a key from the config file.

    @param {String} key The key to lookup (supports dot-notation)
    @returns {*} The value of the key

  **/

  get: function(key) {
    return _.get(editor.load(), key);
  },


  /**

    Sets a key in the config file.

    @param {String} key The path of the property to set (supports dot-notation)
    @param {*} val The value to set

  **/

  set: function(key, val) {
    _.set(editor.load(), key, val);
  },


  /**

    Removes the property in the config.

    @param {String} key The path of the property to unset (supports dot-notation)

  **/

  unset: function(key) {
    _.unset(editor.load(), key);
  },


  /**

    Saves the config.

  **/

  save: function() {
    fs.writeFileSync(editor.filename, JSON.stringify(editor.load(), null, 2), "utf8");
  },


  /**

    Removes the config file

  **/

  remove: function() {
    fs.unlinkSync(editor.filename);
  }

};

{'fraction_non_alphanumeric': 0.1483050847457627, 'fraction_numerical': 0.0015889830508474577, 'mean_word_length': 2.4972222222222222, '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': '5731626', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1183, 'n_words': 349}