<commit_before>module.exports = function() {
    this.encode = function(s) {
        var dict = {};
        var data = (s + "").split("");
        var out = [];
        var currChar;
        var phrase = data[0];
        var code = 256;
        for (var i = 1; i < data.length; i++) {
            currChar = data[i];
            if (dict[phrase + currChar] != null) {
                phrase += currChar;
            } else {
                out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));
                dict[phrase + currChar] = code;
                code++;
                phrase = currChar;
            }
        }
        out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));

        return out;
    }

    this.decode = function(data) {
        var dict = {};
        var currChar = String.fromCharCode(data[0]);
        var oldPhrase = currChar;
        var out = [currChar];
        var code = 256;
        var phrase;
        for (var i = 1; i < data.length; i++) {

            var currCode = data[i];
            if (currCode < 256) {
                phrase = String.fromCharCode(data[i]);
            } else {
                phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar);
            }
            out += phrase;
            currChar = phrase[0];
            dict[code] = oldPhrase + currChar;
            code++;
            oldPhrase = phrase;
        }
        return out;
    }
}
<commit_msg>better code<commit_after>module.exports = function() {
    this.encode = function(s) {
        let dictionary = {},
            out = [],
            currentChar,
            phrase = s[0],
            code = 256;
        s = (s + "").split("");
        for (let i = 1; i < s.length; i++) {
            currentChar = s[i];
            if (dictionary[phrase + currentChar] != null) {
                phrase += currentChar;
            } else {
                out.push(phrase.length > 1 ? dictionary[phrase] : phrase.charCodeAt(0));
                dictionary[phrase + currentChar] = code;
                code++;
                phrase = currentChar;
            }
        }
        out.push(phrase.length > 1 ? dictionary[phrase] : phrase.charCodeAt(0));
        return out;
    }

    this.decode = function(data) {
        let dictionary = {},
            currentChar = String.fromCharCode(data[0]),
            oldPhrase = currentChar,
            out = [currentChar],
            code = 256,
            phrase;
        for (let i = 1; i < data.length; i++) {
            let currCode = data[i];
            if (currCode < 256) {
                phrase = String.fromCharCode(data[i]);
            } else {
                phrase = dictionary[currCode] ? dictionary[currCode] : (oldPhrase + currentChar);
            }
            out += phrase;
            currentChar = phrase[0];
            dictionary[code] = oldPhrase + currentChar;
            code++;
            oldPhrase = phrase;
        }
        return out;
    }
}

{'fraction_non_alphanumeric': 0.12817089452603472, 'fraction_numerical': 0.012016021361815754, 'mean_word_length': 1.367298578199052, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3567044', 'n_tokens_mistral': 878, 'n_tokens_neox': 836, 'n_words': 197}