<commit_before>module.exports = users;


function users (){
    this.list = [];
}

users.prototype.add = function(usrObj){
    this.list.push(usrObj);
};

users.prototype.remove = function(usrObj){
    var obj = null;
    var index = -1;
    if(!usrObj)
        return;
    var property = 'uname' in usrObj ? 'uname':'socket';
    if(!(property in usrObj))
        return;
    for(var i = 0 ; i < this.list.length ; i++){
        if(list[i][property] == usrObj[property]){
            index = i;
        }
    }
    
    if (index != -1){
        obj = list.splice(index, 1);
    }

    return obj;
};<commit_msg>added update and search functionality<commit_after>module.exports = users;


function users (){
    this.list = [];
}

users.prototype.add = function(usrObj){
    this.list.push(usrObj);
};

users.prototype.remove = function(usrObj){
    var index = this.search(usrObj);
    if(index !== null){
        return this.list.splice(index, 1);
    }
    return null;
};

users.prototype.search = function (usrObj){
    var i;
    if(!usrObj)
        return;
    if(usrObj.socket){
        for(i = 0 ; i < this.list.length ; i++){
            if(this.list[i].socket == usrObj.socket){
                return i;
            }
        }
    }
    
    if(usrObj.uname){
        for(i = 0 ; i < this.list.length ; i++){
            if(this.list[i].uname == usrObj.uname){
                return i;
            }
        }
    }
    return null;
};

users.prototype.update = function (usrObj){
    if(!usrObj.uname){
        return;
    }
    var index = this.search({'socket':usrObj.socket});
    var isExist = this.search({'uname':usrObj.uname});
    if(index !== null && isExist === null){
        this.list[i] = usrObj;
    }
};
{'fraction_non_alphanumeric': 0.16262975778546712, 'fraction_numerical': 0.004036908881199538, 'mean_word_length': 2.0653710247349824, 'pattern_counts': {'":': 0, '<': 6, '<?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': '1704854', 'n_tokens_mistral': 599, 'n_tokens_neox': 587, 'n_words': 116}