<commit_before>// main module of `rcomp` JS client
//
// For an example of using this in command-line applications, read cli.js

const fs = require('fs');
const https = require('https');
const http = require('http');
const url = require('url');
const zlib = require('zlib');


// createProtoRequest( options, base_uri )
//
// construct request for an `rcomp` server. The scheme etc. are
// determined from base_uri, if given. Otherwise, the default
// https://api.fmtools.org is used.
//
// This function is intended for the internal implementation of this
// client library, and the API for it may change without warning.
function createProtoRequest( options, base_uri ) {
    var options = options;
    if (options === undefined) {
        options = {};
    } else if ((typeof options === 'string') && base_uri === undefined) {
        var base_uri = options;
        options = {};
    }
    if (base_uri) {
        var new_host = url.parse(base_uri);
        options.hostname = new_host.hostname;
        options.port = new_host.port;
        if (new_host.protocol === 'http:') {
            if (options.port == null) {
                options.port = '80';
            }
            var scheme = http;
        } else {  // new_host.protocol === 'https:'
            if (options.port == null) {
                options.port = '443';
            }
            var scheme = https;
        }
    } else {
        options.hostname = 'api.fmtools.org';
        options.port = 443;
        var scheme = https;
    }

    return (function (f) {
        return scheme.request(options, f);
    });
}


// This function is entirely similar to find_files() in the Python
// client, except that filesystem calls are asynchronous, and the
// resulting argv is passed to the given callback function.
//
// index is used internally for recursion to track the position in
// argv during parsing, so should not be given by API users, but
// equivalently can be 0 on the first call to find_files().
//
// `options` is used internally to preserve state during callback
// chaining.  It can be ignored by API users.
exports.find_files = (function (command, argv, callback, index, options) {
    if (index === undefined) {
        index = 0;
    }<commit_msg>DOC: TRIV<commit_after>// main module of `rcomp` JS client
//
// For an example of using this in command-line applications, read cli.js

const fs = require('fs');
const https = require('https');
const http = require('http');
const url = require('url');
const zlib = require('zlib');


// createProtoRequest( options, base_uri )
//
// construct request for an `rcomp` server. The scheme etc. are
// determined from base_uri, if given. Otherwise, the default
// https://api.fmtools.org is used.
//
// This function is intended for the internal implementation of this
// client library, and the API for it may change without warning.
function createProtoRequest( options, base_uri ) {
    var options = options;
    if (options === undefined) {
        options = {};
    } else if ((typeof options === 'string') && base_uri === undefined) {
        var base_uri = options;
        options = {};
    }
    if (base_uri) {
        var new_host = url.parse(base_uri);
        options.hostname = new_host.hostname;
        options.port = new_host.port;
        if (new_host.protocol === 'http:') {
            if (options.port == null) {
                options.port = '80';
            }
            var scheme = http;
        } else {  // new_host.protocol === 'https:'
            if (options.port == null) {
                options.port = '443';
            }
            var scheme = https;
        }
    } else {
        options.hostname = 'api.fmtools.org';
        options.port = 443;
        var scheme = https;
    }

    return (function (f) {
        return scheme.request(options, f);
    });
}


// This function is entirely similar to find_files() in the Python
// client, except that filesystem calls are asynchronous, and the
// resulting argv is passed to the given callback function.
//
// `index` is used internally for recursion to track the position in
// argv during parsing, so should not be given by API users, but
// equivalently can be 0 on the first call to find_files().
//
// `options` is used internally to preserve state during callback
// chaining.  It can be ignored by API users.
exports.find_files = (function (command, argv, callback, index, options) {
    if (index === undefined) {
        index = 0;
    }
{'fraction_non_alphanumeric': 0.11857972309066547, 'fraction_numerical': 0.0044662795891022775, 'mean_word_length': 2.4086757990867578, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1414184', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1212, 'n_words': 471}