<commit_before>var EE = require('./event_stream_emitter');
var inherits = require('inherits');
var uuid = require('uuid');

function Session(dataOrId) {
    switch (typeof dataOrId) {
        case 'object':
            this.setData(dataOrId);
            break;
        default:
            this.id = dataOrId || uuid.v4();
            this.results = [];
    }
}

inherits(Session, EE);

Session.prototype.getData = function() {
    return {
        id: this.id,
        results: this.results
    };
};

Session.prototype.setData = function(data) {
    if (this.id !== undefined && data.id !== this.id) throw new Error('session data id mismatch');
    this.results = data.results;
    this.emit('change');
};

Session.prototype.addResult = function(result) {
    this.results.push(result);
    this.emit('resultAdd', result);
    this.emit('change');
};

module.exports = Session;<commit_msg>session: set id on load if none<commit_after>var EE = require('./event_stream_emitter');
var inherits = require('inherits');
var uuid = require('uuid');

function Session(dataOrId) {
    switch (typeof dataOrId) {
        case 'object':
            this.setData(dataOrId);
            break;
        default:
            this.id = dataOrId || uuid.v4();
            this.results = [];
    }
}

inherits(Session, EE);

Session.prototype.getData = function() {
    return {
        id: this.id,
        results: this.results
    };
};

Session.prototype.setData = function(data) {
    if (this.id !== undefined && data.id !== this.id) throw new Error('session data id mismatch');
    if (this.id === undefined) this.id = data.id;
    this.results = data.results;
    this.emit('change');
};

Session.prototype.addResult = function(result) {
    this.results.push(result);
    this.emit('resultAdd', result);
    this.emit('change');
};

module.exports = Session;
{'fraction_non_alphanumeric': 0.15496760259179265, 'fraction_numerical': 0.0010799136069114472, 'mean_word_length': 2.8049281314168377, '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': '2523720', 'n_tokens_mistral': 568, 'n_tokens_neox': 564, 'n_words': 122}