<commit_before>"use strict";
var q = require("q");

// The max length of <realname> in USER commands
var MAX_REAL_NAME_LENGTH = 48;
// The max length of <username> in USER commands
var MAX_USER_NAME_LENGTH = 10;

/**
 * Generate a new IRC username for the given Matrix user on the given server.
 * @param {string} domain The IRC server domain
 * @param {string} userId The matrix user being bridged
 * @return {Promise} resolves to the username {string}.
 */
var generateIdentUsername = function(domain, userId) {
    // @foobar££stuff:domain.com  =>  foobar__stuff_domain_com
    var uname = sanitiseUsername(userId.substring(1), "_");
    if (uname < MAX_USER_NAME_LENGTH) { // bwahaha not likely.
        return uname; 
    }
    uname = uname.substring(0, MAX_USER_NAME_LENGTH);
    /* LONGNAM~1 ing algorithm: (native tildes are replaced with _ above)
     * foobar => foob~1 => foob~2 => ... => foob~9 => foo~10 => foo~11 => ...
     * f~9999 => FAIL.
     *
     * Ideal data structure (Tries): (each level from the root node increases digit count by 1)
     *    .---[f]---.            Translation:
     * 123[o]       [a]743       Up to fo~123 is taken
     *    |                      Up to fa~743 is taken
     * 34[o]                     Up to foo~34 is taken
     *    |                      Up to foot~9 is taken (re-search as can't increment)
     *  9[t]
     *
     * while not_free(uname):
     *   if ~ not in uname:
     *     uname = uname[0:-2] + "~1"    // foobar => foob~1
     *     continue
     *   num = uname.split(~)
     *   TODO
     *   
     * return uname
     */

    return uname;<commit_msg>Linting<commit_after>"use strict";
var q = require("q");

// The max length of <realname> in USER commands
var MAX_REAL_NAME_LENGTH = 48;
// The max length of <username> in USER commands
var MAX_USER_NAME_LENGTH = 10;

/**
 * Generate a new IRC username for the given Matrix user on the given server.
 * @param {string} domain The IRC server domain
 * @param {string} userId The matrix user being bridged
 * @return {Promise} resolves to the username {string}.
 */
var generateIdentUsername = function(domain, userId) {
    // @foobar££stuff:domain.com  =>  foobar__stuff_domain_com
    var uname = sanitiseUsername(userId.substring(1), "_");
    if (uname < MAX_USER_NAME_LENGTH) { // bwahaha not likely.
        return uname;
    }
    uname = uname.substring(0, MAX_USER_NAME_LENGTH);
    /* LONGNAM~1 ing algorithm: (native tildes are replaced with _ above)
     * foobar => foob~1 => foob~2 => ... => foob~9 => foo~10 => foo~11 => ...
     * f~9999 => FAIL.
     *
     * Ideal data structure (Tries):
     * (each level from the root node increases digit count by 1)
     *    .---[f]---.            Translation:
     * 123[o]       [a]743       Up to fo~123 is taken
     *    |                      Up to fa~743 is taken
     * 34[o]                     Up to foo~34 is taken
     *    |                      Up to foot~9 is taken (re-search as can't increment)
     *  9[t]
     *
     * while not_free(uname):
     *   if ~ not in uname:
     *     uname = uname[0:-2] + "~1"    // foobar => foob~1
     *     continue
     *   num = uname.split(~)
     *   TODO
     *
     * return uname
     */

    return uname;
{'fraction_non_alphanumeric': 0.12319508448540707, 'fraction_numerical': 0.025192012288786484, 'mean_word_length': 2.0921177587844255, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5789094', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1049, 'n_words': 327}