<commit_before>/**
 * A collection of string utilities
 */

exports.trim = function(line) {
	return String(line).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};

exports.trimZeros = function (num) {
    var str = new String(num || '0');
    if (str.indexOf('.') == -1)
        return str;
    return str.replace(/\.?0*$/, '');
};

exports.ucfirst = function (text) {
    if (!text)
        return text;
    return text[0].toUpperCase() + text.substr(1);
};

exports.lcfirst = function (text) {
    if (!text)
        return text;
    return text[0].toLowerCase() + text.substr(1);
};

exports.formatCurrency = !OS_MOBILEWEB ? String.formatCurrency : function (amount) {
    var num = isNaN(amount) || amount === '' || amount === null ? 0.00 : amount;
    return '$' + parseFloat(num).toFixed(2);
};<commit_msg>urlToJson and urlDecode added in string builtins<commit_after>/**
 * A collection of string utilities
 */

exports.trim = function(line) {
	return String(line).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};

exports.trimZeros = function (num) {
    var str = new String(num || '0');
    if (str.indexOf('.') == -1)
        return str;
    return str.replace(/\.?0*$/, '');
};

exports.ucfirst = function (text) {
    if (!text)
        return text;
    return text[0].toUpperCase() + text.substr(1);
};

exports.lcfirst = function (text) {
    if (!text)
        return text;
    return text[0].toLowerCase() + text.substr(1);
};

exports.formatCurrency = !OS_MOBILEWEB ? String.formatCurrency : function (amount) {
    var num = isNaN(amount) || amount === '' || amount === null ? 0.00 : amount;
    return '$' + parseFloat(num).toFixed(2);
};

exports.urlDecode = function (string){
    if (!string) {
        return '';
    }
    return string.replace(/%[a-fA-F0-9]{2}/ig, function (match) {
        return String.fromCharCode(parseInt(match.replace('%', ''), 16));
    });
};

exports.urlToJson = function (url){
    var list = {};
    var urlarr = url.split('&');
    for (var n = 0; n < urlarr.length; ++n) {
        var item = urlarr[n];
        if (item == "") { continue; }
        var e = item.indexOf('='),
        	name,
			value;
        if (e < 0) {
            name = item;
            value = null;
        } else {
            name = item.substring(0, e);
            value = item.substring(e + 1);
        }
        list[name] = value;
    }						
	return list;		
};
{'fraction_non_alphanumeric': 0.19331941544885178, 'fraction_numerical': 0.012943632567849687, 'mean_word_length': 2.523529411764706, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2452301', 'n_tokens_mistral': 822, 'n_tokens_neox': 811, 'n_words': 185}