<commit_before>/*
* @Author: <NAME>
* @Date:   2016-08-13 20:28:25
* @Last Modified by:   <NAME>
* @Last Modified time: 2016-08-16 21:02:42
*/

'use strict';

const mv = require('mv');
const fs = require('fs');
const path = require('path');

class Helper {

  constructor() { }

  mkdir(path) {
    try {
      fs.mkdirSync(path);
    } catch (err) {
      if (err.code != 'EEXIST') {
        throw new Error("Error occurred while creating a new directory");
      }
    }
  }

  getExtension(fileName) {
    let i = fileName.lastIndexOf('.');
    return (i < 0) ? '' : fileName.substr(i + 1);
  }

  getFileNames(directory) {
    return fs.readdirSync(directory);
  }

  organize(directory, fileName, type) {
    let dir = path.resolve(directory, type);
    this.mkdir(dir);
    mv(path.resolve(directory, fileName), path.resolve(dir, fileName), function (err) {
      if (err) {
        throw new Error("Couldn't move " + fileName + " because of following error: " + err);
      }
    });
  }
}

module.exports = Helper;
<commit_msg>Refactor: Use of Arrow functions<commit_after>/*
* @Author: <NAME>
* @Date:   2016-08-13 20:28:25
* @Last Modified by:   <NAME>
* @Last Modified time: 2017-01-03 22:37:23
*/

'use strict';

const mv = require('mv');
const fs = require('fs');
const path = require('path');

class Helper {

  constructor() { }

  mkdir(path) {
    try {
      fs.mkdirSync(path);
    } catch (err) {
      if (err.code !== 'EEXIST') {
        throw new Error("Error occurred while creating a new directory");
      }
    }
  }

  getExtension(fileName) {
    let i = fileName.lastIndexOf('.');
    return (i < 0) ? '' : fileName.substr(i + 1);
  }

  getFileNames(directory) {
    return fs.readdirSync(directory);
  }

  organize(directory, fileName, type) {
    let dir = path.resolve(directory, type);
    this.mkdir(dir);

    mv(path.resolve(directory, fileName), path.resolve(dir, fileName), (err) => {
      if (err) {
        throw new Error("Couldn't move " + fileName + " because of following error: " + err);
      }
    });
  }
}

module.exports = Helper;

{'fraction_non_alphanumeric': 0.16498800959232615, 'fraction_numerical': 0.02877697841726619, 'mean_word_length': 2.8917910447761193, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, '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': '5571330', 'n_tokens_mistral': 767, 'n_tokens_neox': 716, 'n_words': 175}