<commit_before>/*! Kernel CI Dashboard | Licensed under the GNU GPL v3 (or later) */
define([
    'jquery'
], function($) {
    'use strict';
    var get,
        post,
        request,
        settings,
        token = null;

    if (document.querySelector('meta[name=csrf-token]') !== null) {
        token = document.querySelector('meta[name=csrf-token]').content;
    }

    settings = {
        traditional: true,
        cache: true,
        dataType: 'json',
        timeout: 35000,
        beforeSend: function(jqXHR) {
            jqXHR.setRequestHeader('X-CSRFToken', token);
        }
    };

    get = function(url, data) {
        return request('GET', url, data);
    };

    post = function(url, data) {
        return request('POST', url, data);
    };

    request = function(method, url, data) {
        settings.headers = {'Content-Type': 'application/json'};
        settings.type = method;

        if (data === null || data === undefined) {
            data = {};
        }
        settings.data = data;

        return $.ajax(url, settings);
    };

    return {
        get: get,
        post: post
    };
});<commit_msg>Clean up code on request creation<commit_after>/*! Kernel CI Dashboard | Licensed under the GNU GPL v3 (or later) */
define([
    'jquery'
], function($) {
    'use strict';
    var request,
        settings;

    request = {};
    settings = {
        traditional: true,
        cache: true,
        dataType: 'json',
        timeout: 35000,
        beforeSend: function(jqXHR) {
            jqXHR.setRequestHeader('X-CSRFToken', _getToken());
        }
    };

    function _getToken() {
        var token;

        token = null;
        if (document.querySelector('meta[name=csrf-token]') !== null) {
            token = document.querySelector('meta[name=csrf-token]').content;
        }
        return token;
    }

    function _makeRequest(method, url, data) {
        settings.headers = {'Content-Type': 'application/json'};
        settings.type = method;

        if (!data) {
            data = {};
        }
        settings.data = data;

        return $.ajax(url, settings);
    }

    request.get = function(url, data) {
        return _makeRequest('GET', url, data);
    };

    request.post = function(url, data) {
        return _makeRequest('POST', url, data);
    };

    return request;
});
{'fraction_non_alphanumeric': 0.1435244161358811, 'fraction_numerical': 0.005095541401273885, 'mean_word_length': 1.9747474747474747, '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': '2640476', 'n_tokens_mistral': 715, 'n_tokens_neox': 687, 'n_words': 166}