<commit_before>'use strict';

class APIRequestMgr {
    constructor() {
        this.pageMgr = new PageMgr();
    }

    /**
     * @param {string}        requestMethod
     * @param {string}        requestURL
     * @param {string|Object} [requestData]
     * @param {function}      [onSuccess]
     * @param {function}      [onError]
     */
    request(requestMethod, requestURL, requestData, onSuccess, onError) {
        let self = this;

        if (requestData instanceof Object) {
            requestData = JSON.stringify(requestData);
        }

        $.ajax({
            contentType: 'application/json; charset=utf-8',
            accepts: 'application/json',
            dataType: 'json',
            method: requestMethod,
            url: requestURL,
            data: requestData,
            timeout: APIRequestMgr.resources.config.timeout,
            beforeSend: function () {
                self.pageMgr.loadingMode(true);
                console.log(` >>> ${requestMethod} :: ${requestURL}`, requestData);
            },
            complete: function (jqXHR) {
                self.pageMgr.loadingMode(false);
                console.log(` >>> ${requestMethod} :: ${requestURL}`, jqXHR);
            },
            success: onSuccess,
            error: onError
        });
    }
}

APIRequestMgr.resources = {
    config: {
        /** @type {number} */
        timeout: 5000 /** in milliseconds */
    }
};<commit_msg>improve api mgr<commit_after>'use strict';

class APIRequestMgr {
    constructor() {
        this.pageMgr = new PageMgr();
    }

    /**
     * @param {string}        requestMethod
     * @param {string}        requestURL
     * @param {string|Object} [requestData]
     * @param {function}      [onSuccess]
     * @param {function}      [onError]
     */
    request(requestMethod, requestURL, requestData, onSuccess, onError) {
        let self = this;

        if (requestData instanceof Object) {
            requestData = JSON.stringify(requestData);
        }

        $.ajax({
            contentType: 'application/json; charset=utf-8',
            accepts: 'application/json',
            dataType: 'json',
            method: requestMethod,
            url: requestURL,
            data: requestData,
            timeout: self.constructor.resources.config.defaultTimeout,
            beforeSend: function () {
                self.pageMgr.loadingMode(true);
                console.log(` >>> ${requestMethod} :: ${requestURL}`, requestData);
            },
            complete: function (jqXHR) {
                self.pageMgr.loadingMode(false);
                console.log(` >>> ${requestMethod} :: ${requestURL}`, jqXHR);
            },
            success: onSuccess,
            error: onError
        });
    }
}

APIRequestMgr.resources = {
    config: {
        /** @type {number} */
        defaultTimeout: 5000 /** in milliseconds */
    }
};
{'fraction_non_alphanumeric': 0.1283109735122119, 'fraction_numerical': 0.0034399724802201583, 'mean_word_length': 1.780114722753346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3406146', 'n_tokens_mistral': 794, 'n_tokens_neox': 778, 'n_words': 162}