<commit_before>/**
 * @file sauceQueryHandler.js
 * @description Sagiri thin client for Clara
 * @author Capuccino
 * @license MIT
 * 
 */

const got = require('got');
const urlRegex = str => /(http(s)?:\/\/)?(www\.)?[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi.test(str);

/** 
 * Query Handler for SauceNao-related requests.
 */

class SauceHandler {
    /**
     * @param {String} key your API Key for Saucenao
     * @param {Number} outputType type of output you want the API to show. Default is value 2 (JSON Response)
     * @param {Number} numRes amount of responses you want returned from the API. Default is 5 Responses.
     * @see {link} https://saucenao.com/user.php?page=search-api
     */
    constructor({key, numRes, outputType}) {
        if (!key) throw new TypeError('NO API Key provided!');
        this.key = key,
        this.outputType = outputType || 2,
        this.numRes = numRes || 5;
    }
    /**
     * Gets the source and outputs it in your preferred output type
     * @param {String} path filepath for the image you want to get the source from (Deprecated).
     * @param {String} link web address for the source, must be a valid HTTP/HTTPS address.
     * @returns {Promise} JSON that contains the closest match.
     * @example client.getSauce(path/link).then(res => { console.log(res); });
     */
    getSauce(path, link) {
        return new Promise((resolve, reject) => {
            if (!path === typeof path) {
                throw new TypeError('path is not string');
            } else if (path) {
                /**
                 * @deprecated Due to engineering issues, this is deprecated.
                 */
                throw new Error('This function is deprecated. Use URL links instead');
                /* got(`http://saucenao.com/search.php?output_type=${this.outputType}&numres=${this.numRes}&api_key=${this.key}`, {}).then(res => {               
                 });*/
            } else if (link) {
                if (!urlRegex) {
                    throw new TypeError('Link is not valid HTTP/HTTPS Address.');
                } else {
                    got(`http://saucenao.com/search.php?output_type=${this.outputType}&numres=${this.numRes}&api_key=${this.key}&url=${encodeURIComponent(link)}`).then(res => {
                        resolve(res.body);
                    }).catch(reject);
                }
            }
        });
    }
}

module.exports = SauceHandler;<commit_msg>properly deprecate this function]<commit_after>/**
 * @file sauceQueryHandler.js
 * @description Sagiri thin client for Clara
 * @author Capuccino
 * @license MIT
 * 
 */

const got = require('got');
const urlRegex = str => /(http(s)?:\/\/)?(www\.)?[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi.test(str);

/** 
 * Query Handler for SauceNao-related requests.
 */

class SauceHandler {
    /**
     * @param {String} key your API Key for Saucenao
     * @param {Number} outputType type of output you want the API to show. Default is value 2 (JSON Response)
     * @param {Number} numRes amount of responses you want returned from the API. Default is 5 Responses.
     * @see {link} https://saucenao.com/user.php?page=search-api
     */
    constructor({key, numRes, outputType}) {
        if (!key) throw new TypeError('NO API Key provided!');
        this.key = key,
        this.outputType = outputType || 2,
        this.numRes = numRes || 5;
    }
    /**
     * Gets the source and outputs it in your preferred output type
     * @param {String} path filepath for the image you want to get the source from (Deprecated).
     * @param {String} link web address for the source, must be a valid HTTP/HTTPS address.
     * @returns {Promise} JSON that contains the closest match.
     * @example client.getSauce(path/link).then(res => { console.log(res); });
     */
    getSauce(path, link) {
        return new Promise((resolve, reject) => {
            if (path) {
                /** @deprecated Since there is no native MIMEtype support that isn't ugly
                 *  this is deprecated
                 */
                throw new Error('This function is deprecated.');
            } else if (link) {
                if (!urlRegex) {
                    throw new TypeError('Link is not valid HTTP/HTTPS Address.');
                } else {
                    got(`http://saucenao.com/search.php?output_type=${this.outputType}&numres=${this.numRes}&api_key=${this.key}&url=${encodeURIComponent(link)}`).then(res => {
                        resolve(res.body);
                    }).catch(reject);
                }
            }
        });
    }
}

module.exports = SauceHandler;
{'fraction_non_alphanumeric': 0.1505922165820643, 'fraction_numerical': 0.005922165820642978, 'mean_word_length': 2.1380225613802257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1875721', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1384, 'n_words': 391}