<commit_before>'use strict';

const rendy = require('rendy');
const messages = require('../json/messages');
const DIR = './';

module.exports = (options) => {
    if (!options)
        throw Error('options could not be empty!');
    
    return new Userito(options);
};

function Userito(options) {
    const type = options.type;
    
    if (type === 'file') {
        this._users = require(DIR + 'file')(options.path, options.schema);
        return;
    }
    
    if (type === 'db') {
        if (!options.db)
            throw Error('options.db could not be empty!');
        
        this._users = require(DIR + 'db')(options.db, options.schema);
        return;
    }
    
    throw Error('options.type could be "file" or "db" only!');
}

Userito.prototype.all = function(callback) {
    this._users.all(callback);
};

Userito.prototype.get = function(username, callback) {
    this._users.get(username, (error, user) => {
        let notFoundError;
        
        if (!error && !user)
            notFoundError = {
                message: rendy(messages.notFound, {
                    username: username
                })
            };
        
        callback(error, user, notFoundError);
    });
};

Userito.prototype.create = function(params, callback) {<commit_msg>feature(userito) shorthand properties<commit_after>'use strict';

const rendy = require('rendy');
const messages = require('../json/messages');
const DIR = './';

module.exports = (options) => {
    if (!options)
        throw Error('options could not be empty!');
    
    return new Userito(options);
};

function Userito(options) {
    const type = options.type;
    
    if (type === 'file') {
        this._users = require(DIR + 'file')(options.path, options.schema);
        return;
    }
    
    if (type === 'db') {
        if (!options.db)
            throw Error('options.db could not be empty!');
        
        this._users = require(DIR + 'db')(options.db, options.schema);
        return;
    }
    
    throw Error('options.type could be "file" or "db" only!');
}

Userito.prototype.all = function(callback) {
    this._users.all(callback);
};

Userito.prototype.get = function(username, callback) {
    this._users.get(username, (error, user) => {
        if (!error && !user)
            return callback(Error(rendy(messages.notFound, {
                username
            })));
        
        callback(error, user);
    });
};

Userito.prototype.create = function(params, callback) {
{'fraction_non_alphanumeric': 0.15220883534136545, 'fraction_numerical': 0.0, 'mean_word_length': 2.294973544973545, 'pattern_counts': {'":': 0, '<': 3, '<?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': '176585', 'n_tokens_mistral': 738, 'n_tokens_neox': 732, 'n_words': 167}