<commit_before>let xml2js = require('xml2js').parseString,
    utils = require('./utils.js'),
    https = require('https');

    
/**
 * Makes a HTTP GET request to the specified URL.
 * @param {String} url - URL to make a GET request to
 * @param {Function} callback - Callback function containing the returned XML String.
 */
function GetRequest(url, callback) {
    let xml = '';

    https.get(url, (result) => {
        result.on('data', (data) => {
            xml += data;
        });

        result.on('end', _ => {
            callback(xml);
        });
    });
}

/**
 * Splits an array into a properly formatted string for URL 
 * @param {Array} arr - The array to split and restructure 
 */
function arrToUrl(arr) {
    if(arr.length == 1) {
        return arr[0];
    }

    return arr.join('+');
}

/**
 * Builds the URL to make a GET request to.
 * @param {Object} props - Passed to getCareers as an object with search parameters.
 */
function UrlBuilder(props) {

    let builtUrl = utils.UrlPrefix;

    if(props.query) { builtUrl += props.query }

    if(props.location) { builtUrl += utils.Location + props.location }

    if(props.techDisliked) { 
        builtUrl += utils.TechDisliked + arrToUrl(props.techDisliked) 
    }

    if(props.techLiked) { 
        builtUrl += utils.TechLiked + arrToUrl(props.techLiked) 
    }

    if(props.unit) { builtUrl += utils.Unit + props.unit }

    return builtUrl;
}

module.exports.getCareers = (props, cb) => {

    if(!utils.validObject(props)) {
        console.log('ERROR: Query object cannot be empty.');
        return;
    }

    let url = UrlBuilder(props);

    var data = GetRequest(url, (data) => {
        console.log(url)
        xml2js(data, (err, jobs) => {
            cb(jobs.rss.channel[0].item)
        });
    });
};<commit_msg>doc updates<commit_after>let xml2js = require('xml2js').parseString,
    utils = require('./utils.js'),
    https = require('https');

    
/**
 * Makes a HTTP GET request to the specified URL.
 * @param {String} url - URL to make a GET request to
 * @param {Function} callback - Callback function containing the returned XML String.
 */
function GetRequest(url, callback) {
    let xml = '';

    https.get(url, (result) => {
        result.on('data', (data) => {
            xml += data;
        });

        result.on('end', _ => {
            callback(xml);
        });
    });
}

/**
 * Splits an array into a properly formatted string for URL 
 * @param {Array} arr - The array to split and restructure 
 */
function arrToUrl(arr) {
    if(arr.length == 1) {
        return arr[0];
    }

    return arr.join('+');
}

/**
 * Builds the URL to make a GET request to.
 * @param {Object} props - Passed to getCareers as an object with search parameters.
 */
function UrlBuilder(props) {

    let builtUrl = utils.UrlPrefix;

    if(props.query) { builtUrl += props.query }

    if(props.location) { builtUrl += utils.Location + props.location }

    if(props.techDisliked) { 
        builtUrl += utils.TechDisliked + arrToUrl(props.techDisliked) 
    }

    if(props.techLiked) { 
        builtUrl += utils.TechLiked + arrToUrl(props.techLiked) 
    }

    if(props.unit) { builtUrl += utils.Unit + props.unit }

    return builtUrl;
}

/**
 * @property {Object} props - Properties for your search
 * @property {String} query - Additional information for the search (eg. "Junior" or "remote full time" etc).
 * @property {String} location - Location for the job search. Make this as specific as possible.
 * @property {String[]} techLiked - An array of technologies prefered. (eg. ["javascript", "c", "Java", "wordpress"])
 * @property {String[]} techDisliked - An array of technologies to filter out. (eg. ["fortran", "c++", "AWS"])
 * @property {String} Unit - Unit of measurement for distance. Typically this should be miles.
 * @param {Function} cb - Callback for the array of objects returned.
 */
function getCareers(props, cb) {

    if(!utils.validObject(props)) {
        console.log('ERROR: Query object cannot be empty.');
        return;
    }

    let url = UrlBuilder(props);

    var data = GetRequest(url, (data) => {
        console.log(url)
        xml2js(data, (err, jobs) => {
            cb(jobs.rss.channel[0].item)
        });
    });
};

module.exports = {
    getCareers,
};
{'fraction_non_alphanumeric': 0.14259216322745188, 'fraction_numerical': 0.0027822861117551586, 'mean_word_length': 2.6221662468513856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '1133748', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1315, 'n_words': 383}