<commit_before>const { randomBytes } = require('crypto');

class Store {
    constructor() {
        this.sessions = new Map();
    }

    getID(length) {
        return randomBytes(length).toString('hex');
    }

    async get(sid) {
        if (!this.sessions.has(sid)) return undefined;
        // We are decoding data coming from our Store, so, we assume it was sanitized before storing
        return JSON.parse(this.sessions.get(sid));
    }

    async set(session, { sid =  this.getID(24), maxAge } = {}) {
        // Just a demo how to use maxAge and some cleanup
        if (this.sessions.has(sid)) {
            const { __timeout } = this.sessions.get(sid);
            if (__timeout) clearTimeout(__timeout);
        }

        if (maxAge) session.__timeout = setTimeout(() => this.destroy(sid), maxAge);
        try {
            // JSON.stringify throws on some conditional, such as circular reference
            this.sessions.set(sid) = JSON.stringify(session);
        } catch (err) {}
        
        return sid;
    }

    async destroy(sid) {
        this.sessions.delete(sid);
    }
}

module.exports = Store;<commit_msg>removed `async` in default Store<commit_after>const { randomBytes } = require('crypto');

class Store {
    constructor() {
        this.sessions = new Map();
    }

    getID(length) {
        return randomBytes(length).toString('hex');
    }

    get(sid) {
        if (!this.sessions.has(sid)) return undefined;
        // We are decoding data coming from our Store, so, we assume it was sanitized before storing
        return JSON.parse(this.sessions.get(sid));
    }

    set(session, { sid =  this.getID(24), maxAge } = {}) {
        // Just a demo how to use maxAge and some cleanup
        if (this.sessions.has(sid)) {
            const { __timeout } = this.sessions.get(sid);
            if (__timeout) clearTimeout(__timeout);
        }

        if (maxAge) session.__timeout = setTimeout(() => this.destroy(sid), maxAge);
        try {
            // JSON.stringify throws on some conditional, such as circular reference
            this.sessions.set(sid) = JSON.stringify(session);
        } catch (err) {}
        
        return sid;
    }

    destroy(sid) {
        this.sessions.delete(sid);
    }
}

module.exports = Store;
{'fraction_non_alphanumeric': 0.12603938730853392, 'fraction_numerical': 0.00175054704595186, 'mean_word_length': 2.1927374301675977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2793317', 'n_tokens_mistral': 676, 'n_tokens_neox': 651, 'n_words': 172}