<commit_before>const Cookies = require('js-cookie');

export function urlEncode(param, key, encode = true) {
    if (!param) {
        return '';
    }

    let paramStr = '';
    if ((/string|number|boolean/).test(typeof param)) {
        paramStr += `&${key}=${(encode ? encodeURIComponent(param) : param)}`;
    } else {
        for (const i in param) {
            const k = (!key) ? i : `${key}[${i}]`;
            paramStr += urlEncode(param[i], k, encode);
        }
    }
    return paramStr;
}

/**
 * Whether the data has a property of cookie
 * 
 * @param {any} data 
 * @returns {boolean}
 */
function dataHasCookies(data) {
    return (
        (data instanceof Object) &&
        (data.hasOwnProperty('cookies')) &&
        (data.cookies instanceof Array)
    );
}

/**
 * Whether the data is a standard cookie format
 * 
 * @param {any} data 
 * @returns {boolean}
 */
function validateCookies(data) {
    return (
        data.name && data.value &&
        (/(string|number)/.test(typeof data.name)) &&
        (/(string|number)/.test(typeof data.value)) &&
        ((data.attributes instanceof Object) || (!data.attributes))
    );
}

export function jsonp(url, cb) {
    const script = document.createElement('script');
    const callbackName = 'jsonp_callback_bh' + Math.round(100000 * Math.random());
<commit_msg>data.value allows an empty string.<commit_after>const Cookies = require('js-cookie');

export function urlEncode(param, key, encode = true) {
    if (!param) {
        return '';
    }

    let paramStr = '';
    if ((/string|number|boolean/).test(typeof param)) {
        paramStr += `&${key}=${(encode ? encodeURIComponent(param) : param)}`;
    } else {
        for (const i in param) {
            const k = (!key) ? i : `${key}[${i}]`;
            paramStr += urlEncode(param[i], k, encode);
        }
    }
    return paramStr;
}

/**
 * Whether the data has a property of cookie
 * 
 * @param {any} data 
 * @returns {boolean}
 */
function dataHasCookies(data) {
    return (
        (data instanceof Object) &&
        (data.hasOwnProperty('cookies')) &&
        (data.cookies instanceof Array)
    );
}

/**
 * Whether the data is a standard cookie format
 * 
 * @param {any} data 
 * @returns {boolean}
 */
function validateCookies(data) {
    return (
        data.name &&
        (data.value || data.value === '') &&
        (/(string|number)/.test(typeof data.name)) &&
        (/(string|number)/.test(typeof data.value)) &&
        ((data.attributes instanceof Object) || (!data.attributes))
    );
}

export function jsonp(url, cb) {
    const script = document.createElement('script');
    const callbackName = 'jsonp_callback_bh' + Math.round(100000 * Math.random());

{'fraction_non_alphanumeric': 0.16629874908020603, 'fraction_numerical': 0.004415011037527594, 'mean_word_length': 2.664420485175202, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5577508', 'n_tokens_mistral': 842, 'n_tokens_neox': 823, 'n_words': 203}