<commit_before>/* attributes */
var baseUrl = "https://slack.com/api/";
var clientID = "14600308501.14604351382";
var clientSecret = "<KEY>";
var redirectUri = "http%3A%2F%2F0.0.0.0%3A12345%2Foauth";

/* Distributes calls of Slack API functions */
WorkerScript.onMessage = function(data) {
    console.log('workerScript onMessage:', JSON.stringify(data));
    if (data.apiMethod === 'oauth.access') {
        oauthAccessRequest(data.apiMethod, data.code);
    } else if(data.apiMethod) {
        genericApiRequest(data.apiMethod, data.token);
    }
    else {
        console.log("Unknown request to workerScript");
    }
}

/* Slack API function wrappers */
function genericApiRequest(apiMethod, token) {
    var endpoint = baseUrl + apiMethod + '?token=' + token;
    console.log('genericApiRequest:', endpoint);
    httpGet(endpoint, apiMethod);
}

function oauthAccessRequest(apiMethod, code) {
    var endpoint = baseUrl + apiMethod +
            '?client_id=' + clientID +
            '&client_secret=' + clientSecret +
            '&code=' + code +
            '&redirect_uri=' + redirectUri;
    console.log('oauth', endpoint);
    httpGet(endpoint, apiMethod);
}

/* private functions (do-stuff-things) */
function httpGet(endpoint, apiMethod) {
    var http = new XMLHttpRequest();

    http.onreadystatechange = function() {<commit_msg>Add optional arguments hash to generic Slack api request<commit_after>/* attributes */
var baseUrl = "https://slack.com/api/";
var clientID = "14600308501.14604351382";
var clientSecret = "<KEY>";
var redirectUri = "http%3A%2F%2F0.0.0.0%3A12345%2Foauth";

/* Distributes calls of Slack API functions */
WorkerScript.onMessage = function(data) {
    console.log('workerScript onMessage:', JSON.stringify(data));
    if (data.apiMethod === 'oauth.access') {
        oauthAccessRequest(data.apiMethod, data.code);
    } else if(data.apiMethod) {
        genericApiRequest(data.apiMethod, data.token, data.arguments);
    }
    else {
        console.log("Unknown request to workerScript");
    }
}

/* Slack API function wrappers */
function genericApiRequest(apiMethod, token, arguments) {
    var endpoint = baseUrl + apiMethod + '?token=' + token;

    if (arguments) {
        for(var key in arguments) {
            endpoint = endpoint + '&' + key + '=' + arguments[key];
        }
    }

    console.log('genericApiRequest:', endpoint);
    httpGet(endpoint, apiMethod);
}

function oauthAccessRequest(apiMethod, code) {
    var endpoint = baseUrl + apiMethod +
            '?client_id=' + clientID +
            '&client_secret=' + clientSecret +
            '&code=' + code +
            '&redirect_uri=' + redirectUri;
    console.log('oauth', endpoint);
    httpGet(endpoint, apiMethod);
}

/* private functions (do-stuff-things) */
function httpGet(endpoint, apiMethod) {
    var http = new XMLHttpRequest();

    http.onreadystatechange = function() {
{'fraction_non_alphanumeric': 0.14000687994496044, 'fraction_numerical': 0.02476780185758514, 'mean_word_length': 3.399394856278366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2951009', 'n_tokens_mistral': 930, 'n_tokens_neox': 883, 'n_words': 194}