<commit_before>var utils = require("./utils");

function CodeManager() {
    this.codes = [];
    this.currentSession = -1;
    this.codesGenerated = false;
}

CodeManager.prototype.nextSession = function() {
    if (this.codes[this.currentSession + 1]) {
        this.currentSession++;
    } else if (this.currentSession === -1) {
        throw "No codes generated";
    } else {
        this.currentSession = -1;
        throw "Out of generated codes";
    }
};

CodeManager.prototype.generateCodes = function(nbrOfUsers, nbrOfCodesPerUser, lengthOfCodes) {
    this.codesGenerated = true;
    return this.codes = utils.generateCodes(nbrOfUsers, nbrOfCodesPerUser, lengthOfCodes);
};

CodeManager.prototype.currentSessionCodes = function() {
    return this.codes[this.currentSession];
};

CodeManager.prototype.isValidCode = function(code) {
    return this.currentSessionCodes().indexOf(code) !== -1;
};

CodeManager.prototype.invalidateCode = function(code) {<commit_msg>Clarify logic around codesGenerated boolean<commit_after>var utils = require("./utils");

function CodeManager() {
    this.codes = [];
    this.currentSession = -1;
    this.codesGenerated = false;
}

CodeManager.prototype.nextSession = function() {
    if (!this.codesGenerated) {
        throw "No codes generated";
    }

    if (this.codes[this.currentSession + 1]) {
        this.currentSession++;
    } else {
        this.currentSession = -1;
        throw "Out of generated codes";
    }
};

CodeManager.prototype.generateCodes = function(nbrOfUsers, nbrOfCodesPerUser, lengthOfCodes) {
    this.codesGenerated = true;
    return this.codes = utils.generateCodes(nbrOfUsers, nbrOfCodesPerUser, lengthOfCodes);
};

CodeManager.prototype.currentSessionCodes = function() {
    return this.codes[this.currentSession];
};

CodeManager.prototype.isValidCode = function(code) {
    return this.currentSessionCodes().indexOf(code) !== -1;
};

CodeManager.prototype.invalidateCode = function(code) {
{'fraction_non_alphanumeric': 0.12803643724696356, 'fraction_numerical': 0.004554655870445344, 'mean_word_length': 3.8935643564356437, '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': '7276269', 'n_tokens_mistral': 579, 'n_tokens_neox': 597, 'n_words': 110}