<commit_before>var fs = require("fs");

var ObjCache = function() {
    this.cacheDir = '.cache/';
    if(!fs.existsSync(this.cacheDir)) {
        throw new Error("Fail to init ObjCache, " + this.cacheDir + " doesn't exists.");
    }
}

ObjCache.prototype.get = function() {
    var file = this.cacheDir + "cache.json";
    return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, {encoding: "UTF-8"})) : null;
}

ObjCache.prototype.set = function(obj) {
    var file = this.cacheDir + "cache.json";
    fs.writeFile(file, JSON.stringify(obj), function(err) {
        if(err) {
            console.error("Fail to write cache to " + file);
            throw err;
        }
    });
}

module.exports = ObjCache;<commit_msg>objCache: JSON.stringify(obj, null , 4)<commit_after>var fs = require("fs");

var ObjCache = function() {
    this.cacheDir = '.cache/';
    if(!fs.existsSync(this.cacheDir)) {
        throw new Error("Fail to init ObjCache, " + this.cacheDir + " doesn't exists.");
    }
}

ObjCache.prototype.get = function() {
    var file = this.cacheDir + "cache.json";
    return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, {encoding: "UTF-8"})) : null;
}

ObjCache.prototype.set = function(obj) {
    var file = this.cacheDir + "cache.json";
    fs.writeFile(file, JSON.stringify(obj, null , 4), function(err) {
        if(err) {
            console.error("Fail to write cache to " + file);
            throw err;
        }
    });
}

module.exports = ObjCache;

{'fraction_non_alphanumeric': 0.1638683680322364, 'fraction_numerical': 0.002686366689053056, 'mean_word_length': 2.900523560209424, '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': '7412247', 'n_tokens_mistral': 500, 'n_tokens_neox': 493, 'n_words': 104}