<commit_before>var camomile = (function (fermata) {

    var my = {};
    var _api;

    var default_callback = function(err, data, headers) {
        if (err) {
            console.log(err);
        } else {
            console.log(data);
        };
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // HELPER FUNCTIONS
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    var _user = function(id_user) {
        user = _api('user');
        if (id_user) {
            user = user(id_user);
        }
        return user;
    };

    var _group = function(id_group) {
        group = _api('group');
        if (id_group) {
            group = group(id_group);
        }
        return group;
    };

    var _corpus = function(id_corpus) {
        corpus = _api('corpus');
        if (id_corpus) {
            corpus = corpus(id_corpus);
        }
        return corpus;
    };

    var _media = function(id_media) {
        media = _api('media');
        if (id_media) {
            media = media(id_media);
        }
        return media;
    };

    var _layer = function(id_layer) {
        layer = _api('layer');
        if (id_layer) {
            layer = layer(id_layer);
        }
        return layer;
    };

    var _annotation = function(id_annotation) {
        annotation = _api('annotation');
        if (id_annotation) {
            annotation = annotation(id_annotation);
        }
        return annotation;
    };

    var _queue = function(id_queue) {
        queue = _api('queue');
        if (id_queue) {
            queue = queue(id_queue);
        }
        return queue;
    };

    var _id = function(result) {
        if (Array.isArray(result)) {
            return result.map(function(x) {return x._id;})
        } else {
            return result._id;
        };
    };

    var _ID = function(callback) {
        return function(err, data, headers) {
            if (!err) { data = _id(data); }
            callback(err, data, headers); 
        };
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // AUTHENTICATION
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    my.login = function(username, password, url, callback) {
        callback = callback || default_callback;

        _api = fermata.json(url);
        
        data = {}; 
        data.username = username;
        data.password = password;

        _api('login').post(data, callback);
    };

    my.logout = function(callback) {
        callback = callback || default_callback;

        _api('logout').post({}, callback);
    };

    my.me = function(callback) {
        callback = callback || default_callback;

        _api('me').get(callback);
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // USERS
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    my.getUsers = function(user, username, callback) {
        callback = callback || default_callback;

        params = {}
        if (username !== undefined) {
            params.username = username;
        }

        // if (returns_id) { callback = _ID(callback); }

        _user(user)(params).get(callback);
    };

    my.createUser = function(username, password, description, role, callback) {
        callback = callback || default_callback;

        data = {};
        data.username = username;
        data.password = password;
        data.description = description || {};
        data.role = role || 'user';

        // if (returns_id) { callback = _ID(callback); }

        _user().post(data, callback);

    };

    my.updateUser = function(user, fields, callback) {<commit_msg>feat: divide getUser and getUsers<commit_after>var camomile = (function (fermata) {

    var my = {};
    var _api;

    var default_callback = function(err, data, headers) {
        if (err) {
            console.log(err);
        } else {
            console.log(data);
        };
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // HELPER FUNCTIONS
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    var _user = function(id_user) {
        user = _api('user');
        if (id_user) {
            user = user(id_user);
        }
        return user;
    };

    var _group = function(id_group) {
        group = _api('group');
        if (id_group) {
            group = group(id_group);
        }
        return group;
    };

    var _corpus = function(id_corpus) {
        corpus = _api('corpus');
        if (id_corpus) {
            corpus = corpus(id_corpus);
        }
        return corpus;
    };

    var _media = function(id_media) {
        media = _api('media');
        if (id_media) {
            media = media(id_media);
        }
        return media;
    };

    var _layer = function(id_layer) {
        layer = _api('layer');
        if (id_layer) {
            layer = layer(id_layer);
        }
        return layer;
    };

    var _annotation = function(id_annotation) {
        annotation = _api('annotation');
        if (id_annotation) {
            annotation = annotation(id_annotation);
        }
        return annotation;
    };

    var _queue = function(id_queue) {
        queue = _api('queue');
        if (id_queue) {
            queue = queue(id_queue);
        }
        return queue;
    };

    var _id = function(result) {
        if (Array.isArray(result)) {
            return result.map(function(x) {return x._id;})
        } else {
            return result._id;
        };
    };

    var _ID = function(callback) {
        return function(err, data, headers) {
            if (!err) { data = _id(data); }
            callback(err, data, headers); 
        };
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // AUTHENTICATION
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    my.login = function(username, password, url, callback) {
        callback = callback || default_callback;

        _api = fermata.json(url);
        
        data = {}; 
        data.username = username;
        data.password = password;

        _api('login').post(data, callback);
    };

    my.logout = function(callback) {
        callback = callback || default_callback;

        _api('logout').post({}, callback);
    };

    my.me = function(callback) {
        callback = callback || default_callback;

        _api('me').get(callback);
    };

    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // USERS
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    my.getUser = function(user, callback) {
        callback = callback || default_callback;

        _user(user).get(callback);
    };


    my.getUsers = function(username, callback) {
        callback = callback || default_callback;

        params = {}
        if (username !== undefined) {
            params.username = username;
        }

        _user()(params).get(callback);
    };

    my.createUser = function(username, password, description, role, callback) {
        callback = callback || default_callback;

        data = {};
        data.username = username;
        data.password = password;
        data.description = description || {};
        data.role = role || 'user';

        // if (returns_id) { callback = _ID(callback); }

        _user().post(data, callback);

    };

    my.updateUser = function(user, fields, callback) {
{'fraction_non_alphanumeric': 0.22982180293501048, 'fraction_numerical': 0.0, 'mean_word_length': 2.019382911392405, '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': '5845780', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2012, 'n_words': 410}