<commit_before>import Jane from './Jane';

export default class Toolkit {

  static cast(val, type) {
    if ((type === 'Date') || (type === 'DateTime'))
      return new Date(val);
    else if (Toolkit.typeOf(val) === 'String')
      return JSON.parse(val);
    else
      return val;
  }

  static createDirectory(dir) {

    try {
      Jane.default.fs.mkdirSync(dir);
    } catch (e) { // One of the parent directory doesn't exist
      // Create all the parents recursively
      Toolkit.createDirectory(Jane.default.path.dirname(dir));
      // And then the directory
      Toolkit.createDirectory(dir);
    }
  }

  static directoryExists(dir) {
    try {
      return Jane.default.fs.statSync(dir).isDirectory();
    } catch (e) {
      return false;
    }
  }

  static get ready() {
    return Jane.default.fs && Jane.default.path && Jane.default.xml2js;
  }

  static getDirectoryPath(filePath) {
    return filePath.substring(0, filePath.lastIndexOf('/') + 1);
  }

  static getEntityName(filePath) {
    return filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
  }

  static getFileName(filePath) {
    return filePath.substring(filePath.lastIndexOf('/') + 1);
  }

  static readXMLFile(path) {
    if (!Toolkit.ready)
      throw "You must call Jane.init(<params>) first";

    var res = null;
    var buffer = Jane.default.fs.readFileSync(path); // sync function

    Jane.default.xml2js.parseString(buffer, function(err, obj) { // sync function
      if (err)
        throw err;

      res = obj;
    });

    return res;
  }

  static typeOf(val) {
    return Object.prototype.toString.call(val).match(/\[object (.*)\]/)[1];
  }
}<commit_msg>Added Toolkit.values(object)<commit_after>import Jane from './Jane';

export default class Toolkit {

  static cast(val, type) {
    if ((type === 'Date') || (type === 'DateTime'))
      return new Date(val);
    else if (Toolkit.typeOf(val) === 'String')
      return JSON.parse(val);
    else
      return val;
  }

  static createDirectory(dir) {

    try {
      Jane.default.fs.mkdirSync(dir);
    } catch (e) { // One of the parent directory doesn't exist
      // Create all the parents recursively
      Toolkit.createDirectory(Jane.default.path.dirname(dir));
      // And then the directory
      Toolkit.createDirectory(dir);
    }
  }

  static directoryExists(dir) {
    try {
      return Jane.default.fs.statSync(dir).isDirectory();
    } catch (e) {
      return false;
    }
  }

  static get ready() {
    return Jane.default.fs && Jane.default.path && Jane.default.xml2js;
  }

  static getDirectoryPath(filePath) {
    return filePath.substring(0, filePath.lastIndexOf('/') + 1);
  }

  static getEntityName(filePath) {
    return filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
  }

  static getFileName(filePath) {
    return filePath.substring(filePath.lastIndexOf('/') + 1);
  }

  static readXMLFile(path) {
    if (!Toolkit.ready)
      throw "You must call Jane.init(<params>) first";

    var res = null;
    var buffer = Jane.default.fs.readFileSync(path); // sync function

    Jane.default.xml2js.parseString(buffer, function(err, obj) { // sync function
      if (err)
        throw err;

      res = obj;
    });

    return res;
  }

  static typeOf(val) {
    return Object.prototype.toString.call(val).match(/\[object (.*)\]/)[1];
  }

  static values(object) {
    var values = [];

    for (let key in object)
      values.push(object[key]);

    return values;
  }
}
{'fraction_non_alphanumeric': 0.1459398069278819, 'fraction_numerical': 0.003975014196479273, 'mean_word_length': 2.7759914255091105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3461046', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1106, 'n_words': 255}